Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-11-16 06:35:02
Exec Total Coverage
Lines: 1682 4263 39.5%
Functions: 132 333 39.6%
Branches: 933 3030 30.8%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/version.h"
16 #include "base/zc_alleg.h"
17 #include "gamedata.h"
18 #include "zc/zc_init.h"
19 #include "init.h"
20 #include "zc/replay.h"
21 #include "zc/cheats.h"
22 #include "zc/render.h"
23 #include "base/zc_math.h"
24 #include "base/zapp.h"
25 #include "dialog/cheatkeys.h"
26 #include "metadata/metadata.h"
27 #include "zc/zelda.h"
28 #include "zc/saves.h"
29 #include "tiles.h"
30 #include "base/colors.h"
31 #include "pal.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 #include "zc/zc_sys.h"
35 #include "play_midi.h"
36 #include "gui/jwin_a5.h"
37 #include "base/jwinfsel.h"
38 #include "base/gui.h"
39 #include "midi.h"
40 #include "subscr.h"
41 #include "zc/maps.h"
42 #include "sprite.h"
43 #include "zc/guys.h"
44 #include "zc/hero.h"
45 #include "zc/title.h"
46 #include "particles.h"
47 #include "sound/zcmusic.h"
48 #include "zconsole.h"
49 #include "zc/ffscript.h"
50 #include "dialog/info.h"
51 #include "dialog/alert.h"
52 #include "zc/combos.h"
53 #include "zc/jit.h"
54 #include "zc/zc_subscr.h"
55 #include <fmt/format.h>
56 #include "zinfo.h"
57 #include "base/misctypes.h"
58 #include "music_playback.h"
59
60 #ifdef __EMSCRIPTEN__
61 #include "base/emscripten_utils.h"
62 #endif
63
64 using namespace std::chrono_literals;
65
66 extern FFScript FFCore;
67 extern bool Playing;
68 int32_t sfx_voice[WAV_COUNT];
69 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
70 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
71
72 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
73 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
74
75 extern byte monochrome_console;
76
77 extern HeroClass Hero;
78 extern zcmodule moduledata;
79 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
80 extern particle_list particles;
81 extern int32_t loadlast;
82 extern char *sfx_string[WAV_COUNT];
83 byte use_dwm_flush;
84 byte use_save_indicator;
85 int32_t paused_midi_pos = 0;
86 byte midi_suspended = 0;
87 byte zc_192b163_warp_compatibility;
88 char modulepath[2048];
89 bool epilepsyFlashReduction;
90 signed char pause_in_background_menu_init = 0;
91 byte pause_in_background = 0;
92 bool is_sys_pal = false;
93 static bool load_control_called_this_frame;
94 extern PALETTE* hw_palette;
95 extern bool update_hw_pal;
96 extern const char* dmaplist(int32_t index, int32_t* list_size);
97 int32_t getnumber(const char *prompt,int32_t initialval);
98
99 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
100 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
101
102 static const char *qst_module_name = "current_module";
103 #ifdef ALLEGRO_LINUX
104 static const char *samplepath = "samplesoundset/patches.dat";
105 #endif
106 char qst_files_path[2048];
107
108 #ifdef _MSC_VER
109 #define getcwd _getcwd
110 #endif
111
112 bool rF11();
113 bool rI();
114 bool rQ();
115 bool zc_key_pressed();
116
117 #ifdef _WIN32
118
119 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
120 extern "C"
121 {
122 typedef HRESULT(WINAPI *t_DwmFlush)();
123 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
124 }
125
126 void do_DwmFlush()
127 {
128 static HMODULE shell = LoadLibrary("dwmapi.dll");
129
130 if(!shell)
131 return;
132
133 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
134 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
135
136 BOOL enabled;
137 isEnabled(&enabled);
138
139 if(isEnabled)
140 flush();
141 }
142
143 #endif // _WIN32
144
145 83751 bool flash_reduction_enabled(bool check_qr)
146 {
147
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
148 }
149
150 // Dialogue largening
151 void large_dialog(DIALOG *d)
152 {
153 large_dialog(d, 1.5);
154 }
155
156 void large_dialog(DIALOG *d, float RESIZE_AMT)
157 {
158 if(!d[0].d1)
159 {
160 d[0].d1 = 1;
161 int32_t oldwidth = d[0].w;
162 int32_t oldheight = d[0].h;
163 int32_t oldx = d[0].x;
164 int32_t oldy = d[0].y;
165 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
166 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
167 d[0].w = int32_t(d[0].w*RESIZE_AMT);
168 d[0].h = int32_t(d[0].h*RESIZE_AMT);
169
170 for(int32_t i=1; d[i].proc !=NULL; i++)
171 {
172 // Place elements horizontally
173 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
174 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
175
176 if(d[i].proc != d_stringloader)
177 {
178 if(d[i].proc==d_bitmap_proc)
179 {
180 d[i].w *= 2;
181 }
182 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
183 }
184
185 // Place elements vertically
186 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
187 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
188
189 // Vertically resize elements
190 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
191 {
192 d[i].h = int32_t((double)d[i].h*1.5);
193 }
194 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
195 {
196 d[i].y += int32_t((double)d[i].h*0.25);
197 d[i].h = int32_t((double)d[i].h*1.25);
198 }
199 else if(d[i].proc==d_bitmap_proc)
200 {
201 d[i].h *= 2;
202 }
203 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
204
205 // Fix frames
206 if(d[i].proc == jwin_frame_proc)
207 {
208 d[i].x++;
209 d[i].y++;
210 d[i].w-=4;
211 d[i].h-=4;
212 }
213 }
214 }
215
216 for(int32_t i=1; d[i].proc!=NULL; i++)
217 {
218 if(d[i].proc==jwin_slider_proc)
219 continue;
220
221 // Bigger font
222 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
223
224 if(!d[i].dp2 && bigfontproc)
225 {
226 d[i].dp2 = get_zc_font(font_lfont_l);
227 }
228 else if(!bigfontproc)
229 {
230 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
231 }
232
233 // Make checkboxes work
234 if(d[i].proc == jwin_check_proc)
235 d[i].proc = jwin_checkfont_proc;
236 else if(d[i].proc == jwin_radio_proc)
237 d[i].proc = jwin_radiofont_proc;
238 }
239
240 jwin_center_dialog(d);
241 }
242
243
244 /**********************************/
245 /******** System functions ********/
246 /**********************************/
247
248 static char cfg_sect[] = "zeldadx"; //We need to rename this.
249 static char ctrl_sect[] = "Controls";
250 static char sfx_sect[] = "Volume";
251
252 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
253 {
254 return D_O_K;
255 }
256
257 bool is_reserved_key(int c)
258 {
259 switch(c)
260 {
261 case KEY_ESC:
262 return true;
263 }
264 return false;
265 }
266 bool is_reserved_keycombo(int c, int modflag)
267 {
268 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
269 return true;
270 return false;
271 }
272 bool checkcheat(Cheat cheat)
273 {
274 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
275 return true; //Main key pressed
276 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
277 return true; //Alt key pressed
278 return false;
279 }
280 117 void load_default_cheatkeys()
281 {
282 117 memset(cheatkeys, 0, sizeof(cheatkeys));
283 117 cheatkeys[Cheat::Life][0] = KEY_H;
284 117 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
285 117 cheatkeys[Cheat::Magic][0] = KEY_M;
286 117 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
287 117 cheatkeys[Cheat::Rupies][0] = KEY_R;
288 117 cheatkeys[Cheat::Bombs][0] = KEY_B;
289 117 cheatkeys[Cheat::Arrows][0] = KEY_A;
290 117 cheatkeys[Cheat::Clock][0] = KEY_I;
291 117 cheatkeys[Cheat::Walls][0] = KEY_F11;
292 117 cheatkeys[Cheat::Fast][0] = KEY_Q;
293 117 cheatkeys[Cheat::Light][0] = KEY_L;
294 117 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
295 117 cheatkeys[Cheat::Kill][0] = KEY_K;
296 117 cheatkeys[Cheat::GoTo][0] = KEY_G;
297 117 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
298 117 cheatkeys[Cheat::ShowL0][0] = KEY_0;
299 117 cheatkeys[Cheat::ShowL1][0] = KEY_1;
300 117 cheatkeys[Cheat::ShowL2][0] = KEY_2;
301 117 cheatkeys[Cheat::ShowL3][0] = KEY_3;
302 117 cheatkeys[Cheat::ShowL4][0] = KEY_4;
303 117 cheatkeys[Cheat::ShowL5][0] = KEY_5;
304 117 cheatkeys[Cheat::ShowL6][0] = KEY_6;
305 117 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
306 117 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
307 117 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
308 117 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
309 117 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
310 117 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
311 117 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
312 117 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
313 117 }
314 117 void load_game_configs()
315 {
316 117 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
317 117 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
318 117 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
319 117 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
320 117 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
321 117 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
322 117 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
323 117 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
324 117 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
325 117 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
326 117 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
327 117 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
328 117 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
329 117 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
330 117 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
331
332 //cheat modifier keya
333 117 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
334 117 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
335 117 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
336 117 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
337
338 //cheat keys
339 117 load_default_cheatkeys();
340 char buf[256];
341
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4095 times.
4212 for(size_t q = 1; q < Cheat::Last; ++q)
342 {
343
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 if(!bindable_cheat((Cheat)q)) continue;
344 4095 std::string cheatname = cheat_to_string((Cheat)q);
345
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 util::lowerstr(cheatname);
346 4095 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
347
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
348 4095 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
349
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
350 4095 }
351
352
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
353 joystick_index = 0;
354
355 117 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
356 117 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
357 117 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
358 117 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
359 117 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
360 117 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
361 117 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
362 117 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
363 117 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
364 117 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
365
366 117 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
367 117 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
368 117 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
369 117 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
370
371 117 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
372 117 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
373 117 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
374 117 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
375 117 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
376 117 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
377 117 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
378 117 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
379 117 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
380 117 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
381 117 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
382
383 117 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
384 117 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
385 117 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
386 117 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
387
388 117 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
389
390 117 digi_volume = zc_get_config(sfx_sect,"digi",248);
391 117 midi_volume = zc_get_config(sfx_sect,"midi",255);
392 117 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
393 117 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
394 117 pan_style = zc_get_config(sfx_sect,"pan",1);
395 // 1 <= zcmusic_bufsz <= 128
396 117 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
397 117 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
398 117 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
399 117 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
400 117 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
401 117 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
402 117 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
403 117 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
404 117 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
405 #ifdef __EMSCRIPTEN__
406 if (em_is_mobile()) NameEntryMode = 2;
407 #endif
408 117 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
409 117 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
410 117 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
411 117 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
412 117 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
413
414 117 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
415 117 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
416 117 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
417 117 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
418 117 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
419 117 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
420 117 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
421
422 117 loadlast = zc_get_config(cfg_sect,"load_last",0);
423
424 117 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
425
426 117 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
427
428 117 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
429 117 info_opacity = zc_get_config("zc","debug_info_opacity",255);
430 #ifdef _WIN32
431 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
432 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
433 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
434 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
435
436 // This one's for Aero
437 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
438
439 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
440 #else //UNIX
441 117 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
442 117 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
443 117 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
444 #endif
445 117 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
446 117 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
447
448 117 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
449 117 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
450 117 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
451 117 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
452 117 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
453 117 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
454 117 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
455 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
456 117 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
457 117 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
458 117 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
459 117 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
460 117 }
461
462 void save_control_configs(bool kb)
463 {
464 if(kb)
465 {
466 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
467 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
468 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
469 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
470
471 if (!replay_is_replaying())
472 {
473 zc_set_config(ctrl_sect,"key_a",Akey);
474 zc_set_config(ctrl_sect,"key_b",Bkey);
475 zc_set_config(ctrl_sect,"key_s",Skey);
476 zc_set_config(ctrl_sect,"key_l",Lkey);
477 zc_set_config(ctrl_sect,"key_r",Rkey);
478 zc_set_config(ctrl_sect,"key_p",Pkey);
479 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
480 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
481 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
482 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
483 zc_set_config(ctrl_sect,"key_up", DUkey);
484 zc_set_config(ctrl_sect,"key_down", DDkey);
485 zc_set_config(ctrl_sect,"key_left", DLkey);
486 zc_set_config(ctrl_sect,"key_right",DRkey);
487 }
488 }
489 else
490 {
491 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
492 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
493 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
494 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
495 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
496 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
497 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
498 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
499 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
500 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
501 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
502 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
503 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
504 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
505
506 zc_set_config(ctrl_sect,"btn_a",Abtn);
507 zc_set_config(ctrl_sect,"btn_b",Bbtn);
508 zc_set_config(ctrl_sect,"btn_s",Sbtn);
509 zc_set_config(ctrl_sect,"btn_m",Mbtn);
510 zc_set_config(ctrl_sect,"btn_l",Lbtn);
511 zc_set_config(ctrl_sect,"btn_r",Rbtn);
512 zc_set_config(ctrl_sect,"btn_p",Pbtn);
513 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
514 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
515 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
516 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
517
518 zc_set_config(ctrl_sect,"btn_up",DUbtn);
519 zc_set_config(ctrl_sect,"btn_down",DDbtn);
520 zc_set_config(ctrl_sect,"btn_left",DLbtn);
521 zc_set_config(ctrl_sect,"btn_right",DRbtn);
522 }
523 }
524
525 void save_cheatkeys()
526 {
527 char buf[256];
528 for(size_t q = 1; q < Cheat::Last; ++q)
529 {
530 if(!bindable_cheat((Cheat)q)) continue;
531 std::string cheatname = cheat_to_string((Cheat)q);
532 util::lowerstr(cheatname);
533 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
534 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
535 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
536 if(cheatkeys[q][1])
537 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
538 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
539 }
540 }
541
542 void save_game_configs()
543 {
544 packfile_password("");
545
546 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
547
548 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
549 {
550 int o_window_x, o_window_y;
551 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
552 zc_set_config(cfg_sect,"window_x",o_window_x);
553 zc_set_config(cfg_sect,"window_y",o_window_y);
554 }
555
556 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
557 {
558 window_width = al_get_display_width(all_get_display());
559 window_height = al_get_display_height(all_get_display());
560 zc_set_config(cfg_sect,"window_width",window_width);
561 zc_set_config(cfg_sect,"window_height",window_height);
562 }
563
564 zc_set_config(cfg_sect,"load_last",loadlast);
565 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
566
567 flush_config_file();
568 #ifdef __EMSCRIPTEN__
569 em_sync_fs();
570 #endif
571 }
572
573 //----------------------------------------------------------------
574
575 // Timers
576
577 31607 void fps_callback()
578 {
579 31607 lastfps=framecnt;
580 31607 framecnt=0;
581 31607 }
582
583 END_OF_FUNCTION(fps_callback)
584
585 117 int32_t Z_init_timers()
586 {
587 static bool didit = false;
588 const static char *err_str = "Couldn't allocate timer";
589 117 err_str = err_str; //Unused variable warning
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(didit)
592 return 1;
593
594 117 didit = true;
595
596 LOCK_VARIABLE(lastfps);
597 LOCK_VARIABLE(framecnt);
598 LOCK_FUNCTION(fps_callback);
599
600
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
601 return 0;
602
603 117 return 1;
604 117 }
605
606 void Z_remove_timers()
607 {
608 remove_int(fps_callback);
609 }
610
611 //----------------------------------------------------------------
612
613 void go()
614 {
615 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
616 }
617
618 void comeback()
619 {
620 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
621 }
622
623 void dump_pal(BITMAP *dest)
624 {
625 for(int32_t i=0; i<256; i++)
626 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
627 }
628
629 //----------------------------------------------------------------
630
631 int game_mouse_index = ZCM_BLANK;
632 static bool system_mouse = false;
633 28 bool sys_mouse()
634 {
635 28 system_mouse = true;
636 28 return MouseSprite::set(ZCM_NORMAL);
637 }
638 561 bool game_mouse()
639 {
640 561 system_mouse = false;
641 561 return MouseSprite::set(game_mouse_index);
642 }
643 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
644 {
645 if(!bmp)
646 return;
647 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
648 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
649 if(bmp->w == scaledw && bmp->h == scaledh)
650 user_scale = false;
651 if(user_scale || sys_recolor)
652 {
653 if(!user_scale) scale = 1;
654 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
655 if(user_scale)
656 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
657 else
658 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
659 if(sys_recolor)
660 recolor_mouse(tmpbmp);
661 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
662 destroy_bitmap(tmpbmp);
663 }
664 else
665 {
666 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
667 }
668 }
669
670 //Handles converting the mouse sprite from the .dat file
671 void recolor_mouse(BITMAP* bmp)
672 {
673 for(int32_t x = 0; x < bmp->w; ++x)
674 {
675 for(int32_t y = 0; y < bmp->h; ++y)
676 {
677 int32_t color = getpixel(bmp, x, y);
678 switch(color)
679 {
680 case dvc(1):
681 color = jwin_pal[jcCURSORMISC];
682 break;
683 case dvc(2):
684 color = jwin_pal[jcCURSOROUTLINE];
685 break;
686 case dvc(3):
687 color = jwin_pal[jcCURSORLIGHT];
688 break;
689 case dvc(5):
690 color = jwin_pal[jcCURSORDARK];
691 break;
692 default:
693 continue;
694 }
695 putpixel(bmp, x, y, color);
696 }
697 }
698 }
699 void load_mouse()
700 {
701 PALETTE pal;
702 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
703 if (!cursor_bitmap)
704 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
705
706 enter_sys_pal();
707 MouseSprite::set(-1);
708 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
709 int32_t sz = 16*scale;
710 for(int32_t j = 0; j < 1; ++j)
711 {
712 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
713 if(zcmouse[j])
714 destroy_bitmap(zcmouse[j]);
715 zcmouse[j] = create_bitmap_ex(8,sz,sz);
716 clear_bitmap(zcmouse[j]);
717 clear_bitmap(tmpbmp);
718 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
719 recolor_mouse(tmpbmp);
720 if(sz!=16)
721 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
722 else
723 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
724 destroy_bitmap(tmpbmp);
725 }
726 if(!hw_palette) hw_palette = &RAMpal;
727 zc_set_palette(*hw_palette);
728
729 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
730 clear_bitmap(blankmouse);
731
732 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
733 MouseSprite::assign(ZCM_BLANK, blankmouse);
734 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
735
736 //Reload the mouse
737 if(system_mouse)
738 sys_mouse();
739 else game_mouse();
740
741 destroy_bitmap(blankmouse);
742 destroy_bitmap(cursor_bitmap);
743 exit_sys_pal();
744 }
745
746 // sets the video mode and initializes the palette and mouse sprite
747 117 bool game_vid_mode(int32_t mode,int32_t wait)
748 {
749
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if (is_headless())
750 117 return true;
751
752 extern int zq_screen_w, zq_screen_h;
753 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
754 {
755 return false;
756 }
757
758 scrx = (resx-320)>>1;
759 scry = (resy-240)>>1;
760 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
761 zcmouse[q] = NULL;
762 load_mouse();
763
764 for(int32_t i=240; i<256; i++)
765 RAMpal[i]=pal_gui[i];
766
767 zc_set_palette(RAMpal);
768 clear_to_color(screen,BLACK);
769
770 rest(wait);
771 return true;
772 117 }
773
774 8 void null_quest()
775 {
776 char qstdat_string[2048];
777 8 strcpy(qstdat_string, "modules/classic/default.qst");
778
779 #ifdef __EMSCRIPTEN__
780 // The quest template data file is not included because it's really big and isn't really needed
781 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
782 // which is much smaller.
783 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
784 #endif
785
786 8 byte skip_flags[4] = { 0 };
787
788 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
789 8 }
790
791 8 void init_NES_mode()
792 {
793 8 null_quest();
794 8 }
795
796 //----------------------------------------------------------------
797
798 qword trianglelines[16]=
799 {
800 0x0000000000000000ULL,
801 0xFD00000000000000ULL,
802 0xFDFD000000000000ULL,
803 0xFDFDFD0000000000ULL,
804 0xFDFDFDFD00000000ULL,
805 0xFDFDFDFDFD000000ULL,
806 0xFDFDFDFDFDFD0000ULL,
807 0xFDFDFDFDFDFDFD00ULL,
808 0xFDFDFDFDFDFDFDFDULL,
809 0x00FDFDFDFDFDFDFDULL,
810 0x0000FDFDFDFDFDFDULL,
811 0x000000FDFDFDFDFDULL,
812 0x00000000FDFDFDFDULL,
813 0x0000000000FDFDFDULL,
814 0x000000000000FDFDULL,
815 0x00000000000000FDULL,
816 };
817
818 word screen_triangles[28][32];
819 /*
820 qword triangles[4][16]= //[direction][value]
821 {
822 {
823 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
824 },
825 {
826 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
827 },
828 {
829 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
830 },
831 {
832 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
833 }
834 };
835 */
836
837
838 /*
839 byte triangles[4][16][8]= //[direction][value][line]
840 {
841 {
842 {
843 0, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 1, 0, 0, 0, 0, 0, 0, 0
847 },
848 {
849 2, 1, 0, 0, 0, 0, 0, 0
850 },
851 {
852 3, 2, 1, 0, 0, 0, 0, 0
853 },
854 {
855 4, 3, 2, 1, 0, 0, 0, 0
856 },
857 {
858 5, 4, 3, 2, 1, 0, 0, 0
859 },
860 {
861 6, 5, 4, 3, 2, 1, 0, 0
862 },
863 {
864 7, 6, 5, 4, 3, 2, 1, 0
865 },
866 {
867 8, 7, 6, 5, 4, 3, 2, 1
868 },
869 {
870 8, 8, 7, 6, 5, 4, 3, 2
871 },
872 {
873 8, 8, 8, 7, 6, 5, 4, 3
874 },
875 {
876 8, 8, 8, 8, 7, 6, 5, 4
877 },
878 {
879 8, 8, 8, 8, 8, 7, 6, 5
880 },
881 {
882 8, 8, 8, 8, 8, 8, 7, 6
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 7
886 },
887 {
888 8, 8, 8, 8, 8, 8, 8, 8
889 }
890 },
891 {
892 {
893 0, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 15, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 14, 15, 0, 0, 0, 0, 0, 0
900 },
901 {
902 13, 14, 15, 0, 0, 0, 0, 0
903 },
904 {
905 12, 13, 14, 15, 0, 0, 0, 0
906 },
907 {
908 11, 12, 13, 14, 15, 0, 0, 0
909 },
910 {
911 10, 11, 12, 13, 14, 15, 0, 0
912 },
913 {
914 9, 10, 11, 12, 13, 14, 15, 0
915 },
916 {
917 8, 9, 10, 11, 12, 13, 14, 15
918 },
919 {
920 8, 8, 9, 10, 11, 12, 13, 14
921 },
922 {
923 8, 8, 8, 9, 10, 11, 12, 13
924 },
925 {
926 8, 8, 8, 8, 9, 10, 11, 12
927 },
928 {
929 8, 8, 8, 8, 8, 9, 10, 11
930 },
931 {
932 8, 8, 8, 8, 8, 8, 9, 10
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 9
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 8
939 }
940 },
941 {
942 {
943 0, 0, 0, 0, 0, 0, 0, 0
944 },
945 {
946 0, 0, 0, 0, 0, 0, 0, 1
947 },
948 {
949 0, 0, 0, 0, 0, 0, 1, 2
950 },
951 {
952 0, 0, 0, 0, 0, 1, 2, 3
953 },
954 {
955 0, 0, 0, 0, 1, 2, 3, 4
956 },
957 {
958 0, 0, 0, 1, 2, 3, 4, 5
959 },
960 {
961 0, 0, 1, 2, 3, 4, 5, 6
962 },
963 {
964 0, 1, 2, 3, 4, 5, 6, 7
965 },
966 {
967 1, 2, 3, 4, 5, 6, 7, 8
968 },
969 {
970 2, 3, 4, 5, 6, 7, 8, 8
971 },
972 {
973 3, 4, 5, 6, 7, 8, 8, 8
974 },
975 {
976 4, 5, 6, 7, 8, 8, 8, 8
977 },
978 {
979 5, 6, 7, 8, 8, 8, 8, 8
980 },
981 {
982 6, 7, 8, 8, 8, 8, 8, 8
983 },
984 {
985 7, 8, 8, 8, 8, 8, 8, 8
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 8
989 }
990 },
991 {
992 {
993 0, 0, 0, 0, 0, 0, 0, 0
994 },
995 {
996 0, 0, 0, 0, 0, 0, 0, 15
997 },
998 {
999 0, 0, 0, 0, 0, 0, 15, 14
1000 },
1001 {
1002 0, 0, 0, 0, 0, 15, 14, 13
1003 },
1004 {
1005 0, 0, 0, 0, 15, 14, 13, 12
1006 },
1007 {
1008 0, 0, 0, 15, 14, 13, 12, 11
1009 },
1010 {
1011 0, 0, 15, 14, 13, 12, 11, 10
1012 },
1013 {
1014 0, 15, 14, 13, 12, 11, 10, 9
1015 },
1016 {
1017 15, 14, 13, 12, 11, 10, 9, 8
1018 },
1019 {
1020 14, 13, 12, 11, 10, 9, 8, 8
1021 },
1022 {
1023 13, 12, 11, 10, 9, 8, 8, 8
1024 },
1025 {
1026 12, 11, 10, 9, 8, 8, 8, 8
1027 },
1028 {
1029 11, 10, 9, 8, 8, 8, 8, 8
1030 },
1031 {
1032 10, 9, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 9, 8, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 8, 8, 8, 8, 8, 8, 8, 8
1039 }
1040 }
1041 };
1042 */
1043
1044
1045
1046 /*
1047 for (int32_t blockrow=0; blockrow<30; ++i)
1048 {
1049 for (int32_t linerow=0; linerow<8; ++i)
1050 {
1051 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1052 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1053 {
1054 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1055 ++triangleline;
1056 }
1057 }
1058 }
1059 */
1060
1061 // the ULL suffixes are to prevent this warning:
1062 // warning: integer constant is too large for "int32_t" type
1063
1064 qword triangles[4][16][8]= //[direction][value][line]
1065 {
1066 {
1067 {
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL
1076 },
1077 {
1078 0xFD00000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL
1086 },
1087 {
1088 0xFDFD000000000000ULL,
1089 0xFD00000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL
1096 },
1097 {
1098 0xFDFDFD0000000000ULL,
1099 0xFDFD000000000000ULL,
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFDFDFDFD00000000ULL,
1109 0xFDFDFD0000000000ULL,
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFDFDFDFD000000ULL,
1119 0xFDFDFDFD00000000ULL,
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFDFDFDFD0000ULL,
1129 0xFDFDFDFDFD000000ULL,
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFDFDFDFD00ULL,
1139 0xFDFDFDFDFDFD0000ULL,
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFD00ULL,
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL
1226 }
1227 },
1228 {
1229 {
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL
1238 },
1239 {
1240 0x00000000000000FDULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL
1248 },
1249 {
1250 0x000000000000FDFDULL,
1251 0x00000000000000FDULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL
1258 },
1259 {
1260 0x0000000000FDFDFDULL,
1261 0x000000000000FDFDULL,
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000FDFDFDFDULL,
1271 0x0000000000FDFDFDULL,
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000FDFDFDFDFDULL,
1281 0x00000000FDFDFDFDULL,
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000FDFDFDFDFDFDULL,
1291 0x000000FDFDFDFDFDULL,
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00FDFDFDFDFDFDFDULL,
1301 0x0000FDFDFDFDFDFDULL,
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0x00FDFDFDFDFDFDFDULL,
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL
1318 },
1319 {
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL
1328 },
1329 {
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL
1388 }
1389 },
1390 {
1391 {
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL
1400 },
1401 {
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL
1410 },
1411 {
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL
1420 },
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL
1470 },
1471 {
1472 0xFD00000000000000ULL,
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL
1480 },
1481 {
1482 0xFDFD000000000000ULL,
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL
1490 },
1491 {
1492 0xFDFDFD0000000000ULL,
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL
1500 },
1501 {
1502 0xFDFDFDFD00000000ULL,
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFDFDFDFD000000ULL,
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFDFDFDFD0000ULL,
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFDFDFDFD00ULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 }
1551 },
1552 {
1553 {
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL
1562 },
1563 {
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL
1572 },
1573 {
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL
1582 },
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL
1632 },
1633 {
1634 0x00000000000000FDULL,
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL
1642 },
1643 {
1644 0x000000000000FDFDULL,
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000FDFDFDULL,
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000FDFDFDFDULL,
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000FDFDFDFDFDULL,
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000FDFDFDFDFDFDULL,
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00FDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 }
1713 }
1714 };
1715
1716 int32_t black_opening_count=0;
1717 int32_t black_opening_x,black_opening_y;
1718 int32_t black_opening_shape;
1719
1720 1508 int32_t choose_opening_shape()
1721 {
1722 // First, count how many bits are set
1723 1508 int32_t numBits=0;
1724 int32_t bitCounter;
1725
1726
2/2
✓ Branch 0 taken 7540 times.
✓ Branch 1 taken 1508 times.
9048 for(int32_t i=0; i<bosMAX; i++)
1727 {
1728
2/2
✓ Branch 0 taken 5816 times.
✓ Branch 1 taken 1724 times.
7540 if(COOLSCROLL&(1<<i))
1729 1724 numBits++;
1730 7540 }
1731
1732 // Shouldn't happen...
1733
1/2
✓ Branch 0 taken 1508 times.
✗ Branch 1 not taken.
1508 if(numBits==0)
1734 return bosCIRCLE;
1735
1736 // Pick a bit
1737 1508 bitCounter=zc_rand()%numBits+1;
1738
1739
2/2
✓ Branch 0 taken 1993 times.
✓ Branch 1 taken 26 times.
2019 for(int32_t i=0; i<bosMAX; i++)
1740 {
1741 // If this bit is set, decrement the bit counter
1742
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1638 times.
1993 if(COOLSCROLL&(1<<i))
1743 1638 bitCounter--;
1744
1745 // When the counter hits 0, return a value based on
1746 // which bit it stopped on.
1747 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1748
2/2
✓ Branch 0 taken 1482 times.
✓ Branch 1 taken 511 times.
1993 if(bitCounter==0)
1749 1482 return i;
1750 511 }
1751
1752 // Shouldn't be necessary, but the compiler might complain, at least
1753 26 return bosCIRCLE;
1754 1508 }
1755
1756 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1757 {
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1759
1760 396 int32_t w=256, h=224;
1761 396 int32_t blockrows=28, blockcolumns=32;
1762 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1763
1764
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1765 {
1766
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1767 {
1768
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1769 354816 }
1770 11088 }
1771
1772 396 black_opening_count = 66;
1773 396 black_opening_x = x;
1774 396 black_opening_y = y;
1775 396 lensclk = 0;
1776 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1777
1778
1779
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1780 {
1781 refreshTints();
1782 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1783 }
1784
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1785 {
1786 FFCore.warpScriptCheck();
1787 for(int32_t i=0; i<66; i++)
1788 {
1789 draw_screen(tmpscr);
1790 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1791 advanceframe(true);
1792
1793 if(Quit)
1794 {
1795 break;
1796 }
1797 }
1798 }
1799 396 }
1800
1801 1112 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1802 {
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1804
1805 1112 int32_t w=256, h=224;
1806 1112 int32_t blockrows=28, blockcolumns=32;
1807 1112 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1808
1809
2/2
✓ Branch 0 taken 31136 times.
✓ Branch 1 taken 1112 times.
32248 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1810 {
1811
2/2
✓ Branch 0 taken 996352 times.
✓ Branch 1 taken 31136 times.
1027488 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1812 {
1813
2/2
✓ Branch 0 taken 507221 times.
✓ Branch 1 taken 489131 times.
996352 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1814 996352 }
1815 31136 }
1816
1817 1112 black_opening_count = -66;
1818 1112 black_opening_x = x;
1819 1112 black_opening_y = y;
1820 1112 lensclk = 0;
1821
1/2
✓ Branch 0 taken 1112 times.
✗ Branch 1 not taken.
1112 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 913 times.
1112 if(wait)
1827 {
1828 913 FFCore.warpScriptCheck();
1829
2/2
✓ Branch 0 taken 913 times.
✓ Branch 1 taken 60258 times.
61171 for(int32_t i=0; i<66; i++)
1830 {
1831 60258 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1833 60258 advanceframe(true);
1834
1835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60258 times.
60258 if(Quit)
1836 {
1837 break;
1838 }
1839 60258 }
1840 913 }
1841 1112 }
1842
1843 99528 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1844 {
1845 99528 clear_to_color(tmp_scr,BLACK);
1846 99528 int32_t w=256, h=224;
1847
1848
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90354 times.
99528 switch(black_opening_shape)
1849 {
1850 case bosOVAL:
1851 {
1852 858 double new_w=(w/2)+abs(w/2-x);
1853 858 double new_h=(h/2)+abs(h/2-y);
1854 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1855 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1856 858 break;
1857 }
1858
1859 case bosTRIANGLE:
1860 {
1861 660 double new_w=(w/2)+abs(w/2-x);
1862 660 double new_h=(h/2)+abs(h/2-y);
1863 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1864 660 double P2= (PI/2);
1865 660 double P23=(2*PI/3);
1866 660 double P43=(4*PI/3);
1867 660 double Pa= (-4*PI*a/(3*max_a));
1868 660 double angle=P2+Pa;
1869 660 double a0=angle;
1870 660 double a2=angle+P23;
1871 660 double a4=angle+P43;
1872 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1873 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1874 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1875 0);
1876 660 break;
1877 }
1878
1879 case bosSMAS:
1880 {
1881
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1882
1883
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1884 {
1885
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1886 {
1887 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1888
1889
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1890 {
1891 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1892
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1893 54878208 [linerow];
1894 54878208 ++triangleline;
1895
1896
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1897 {
1898 6859776 }
1899 54878208 }
1900 1714944 }
1901 214368 }
1902
1903 7656 break;
1904 }
1905
1906 case bosFADEBLACK:
1907 {
1908 if(black_opening_count<0)
1909 {
1910 black_fade(zc_min(-black_opening_count,63));
1911 }
1912 else if(black_opening_count>0)
1913 {
1914 black_fade(63-zc_max(black_opening_count-3,0));
1915 }
1916 else black_fade(0);
1917 return; //no blitting from tmp_scr!
1918 }
1919
1920 90354 case bosCIRCLE:
1921 default:
1922 {
1923 90354 double new_w=(w/2)+abs(w/2-x);
1924 90354 double new_h=(h/2)+abs(h/2-y);
1925 90354 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1926 //circlefill(tmp_scr,x,y,a<<3,0);
1927 90354 circlefill(tmp_scr,x,y,r,0);
1928 90354 break;
1929 }
1930 }
1931
1932 99528 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1933 99528 }
1934
1935
1936 void black_fade(int32_t fadeamnt)
1937 {
1938 for(int32_t i=0; i < 0xEF; i++)
1939 {
1940 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1941 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1942 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1943 }
1944
1945 refreshpal = true;
1946 }
1947
1948 //----------------------------------------------------------------
1949
1950 38831728 bool item_disabled(int32_t item) //is this item disabled?
1951 {
1952
2/2
✓ Branch 0 taken 1832457 times.
✓ Branch 1 taken 36999271 times.
38831728 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1953 }
1954
1955 7618361 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1956 {
1957
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7483113 times.
7618361 if(current_item(item_type, true) >=item)
1958 {
1959 135248 return true;
1960 }
1961
1962 7483113 return false;
1963 7618361 }
1964
1965 25026143 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1966 {
1967
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 26467 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16170214 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
25026143 switch(item_type)
1968 {
1969 case itype_bomb:
1970 case itype_sbomb:
1971 {
1972 int32_t itemid = getItemID(itemsbuf, item_type, it);
1973
1974 if(itemid == -1)
1975 return false;
1976
1977 return (game->get_item(itemid));
1978 }
1979
1980 case itype_clock:
1981 {
1982 26467 int32_t itemid = getItemID(itemsbuf, item_type, it);
1983
1984
2/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26467 times.
✗ Branch 3 not taken.
26467 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1985 return (game->get_item(itemid));
1986 26467 return Hero.getClock()?1:0;
1987 }
1988
1989 case itype_key:
1990 return (game->get_keys()>0);
1991
1992 case itype_magiccontainer:
1993 return (game->get_maxmagic()>=game->get_mp_per_block());
1994
1995 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1996 {
1997
2/3
✓ Branch 0 taken 280536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2939741 times.
3220277 switch(it)
1998 {
1999 case -2:
2000 {
2001 for(int32_t i=0; i<MAXLEVELS; i++)
2002 {
2003 if(game->lvlitems[i]&liTRIFORCE)
2004 {
2005 return true;
2006 }
2007 }
2008
2009 return false;
2010 }
2011
2012 case -1:
2013 2939741 return (game->lvlitems[dlevel]&liTRIFORCE);
2014
2015 default:
2016
2/4
✓ Branch 0 taken 280536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 280536 times.
280536 if(it>=0&&it<MAXLEVELS)
2017 {
2018 280536 return (game->lvlitems[it]&liTRIFORCE);
2019 }
2020
2021 break;
2022 }
2023
2024 return 0;
2025 }
2026
2027 case itype_map: //it: -2=any, -1=current level, other=that level
2028 {
2029
2/3
✓ Branch 0 taken 402420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15767794 times.
16170214 switch(it)
2030 {
2031 case -2:
2032 {
2033 for(int32_t i=0; i<MAXLEVELS; i++)
2034 {
2035 if(game->lvlitems[i]&liMAP)
2036 {
2037 return true;
2038 }
2039 }
2040
2041 return false;
2042 }
2043
2044 case -1:
2045 15767794 return (game->lvlitems[dlevel]&liMAP)!=0;
2046
2047 default:
2048
2/4
✓ Branch 0 taken 402420 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 402420 times.
402420 if(it>=0&&it<MAXLEVELS)
2049 {
2050 402420 return (game->lvlitems[it]&liMAP)!=0;
2051 }
2052
2053 break;
2054 }
2055
2056 return 0;
2057 }
2058
2059 case itype_compass: //it: -2=any, -1=current level, other=that level
2060 {
2061
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
5493498 switch(it)
2062 {
2063 case -2:
2064 {
2065 for(int32_t i=0; i<MAXLEVELS; i++)
2066 {
2067 if(game->lvlitems[i]&liCOMPASS)
2068 {
2069 return true;
2070 }
2071 }
2072
2073 return false;
2074 }
2075
2076 case -1:
2077 5493498 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2078
2079 default:
2080 if(it>=0&&it<MAXLEVELS)
2081 {
2082 return (game->lvlitems[it]&liCOMPASS)!=0;
2083 }
2084
2085 break;
2086 }
2087 return 0;
2088 }
2089
2090 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 115687 times.
115687 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liBOSSKEY)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 115687 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2109
2110 default:
2111 if(it>=0&&it<MAXLEVELS)
2112 {
2113 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2114 }
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 default:
2121 //it=(1<<(it-1));
2122 /*if (item_type>=itype_max)
2123 {
2124 enter_sys_pal();
2125 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2126 exit_sys_pal();
2127
2128 return false;
2129 }*/
2130 int32_t itemid = getItemID(itemsbuf, item_type, it);
2131
2132 if(itemid == -1)
2133 return false;
2134
2135 return game->get_item(itemid);
2136 }
2137 25026143 }
2138
2139
2140 51803521 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2141 {
2142
9/9
✓ Branch 0 taken 26467 times.
✓ Branch 1 taken 51591785 times.
✓ Branch 2 taken 26467 times.
✓ Branch 3 taken 26467 times.
✓ Branch 4 taken 26467 times.
✓ Branch 5 taken 26467 times.
✓ Branch 6 taken 26467 times.
✓ Branch 7 taken 26467 times.
✓ Branch 8 taken 26467 times.
51803521 switch(item_type)
2143 {
2144 case itype_clock:
2145 {
2146 26467 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2147
2148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26467 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2149 return itemsbuf[maxid].fam_type;
2150
2151 26467 return has_item(itype_clock,1) ? 1 : 0;
2152 }
2153
2154 case itype_key:
2155 26467 return game->get_keys();
2156
2157 case itype_lkey:
2158 26467 return game->lvlkeys[get_dlevel()];
2159
2160 case itype_magiccontainer:
2161 26467 return game->get_maxmagic()/game->get_mp_per_block();
2162
2163 case itype_triforcepiece:
2164 {
2165 26467 int32_t count=0;
2166
2167
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2168 {
2169 13551104 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2170 13551104 }
2171
2172 26467 return count;
2173 }
2174
2175 case itype_map:
2176 {
2177 26467 int32_t count=0;
2178
2179
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2180 {
2181 13551104 count+=(game->lvlitems[i]&liMAP)?1:0;
2182 13551104 }
2183
2184 26467 return count;
2185 }
2186
2187 case itype_compass:
2188 {
2189 26467 int32_t count=0;
2190
2191
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2192 {
2193 13551104 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2194 13551104 }
2195
2196 26467 return count;
2197 }
2198
2199 case itype_bosskey:
2200 {
2201 26467 int32_t count=0;
2202
2203
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2204 {
2205 13551104 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2206 13551104 }
2207
2208 26467 return count;
2209 }
2210
2211 default:
2212 51591785 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2213
2214
2/2
✓ Branch 0 taken 9875888 times.
✓ Branch 1 taken 41715897 times.
51591785 if(maxid == -1)
2215 41715897 return 0;
2216
2217 9875888 return itemsbuf[maxid].fam_type;
2218 }
2219 51803521 }
2220
2221 44185160 int32_t current_item(int32_t item_type) //item currently being used
2222 {
2223 44185160 return current_item(item_type, true);
2224 }
2225
2226 117 std::map<int32_t, int32_t> itemcache;
2227 117 std::map<int32_t, int32_t> itemcache_cost;
2228
2229 void removeFromItemCache(int32_t itemclass)
2230 {
2231 itemcache.erase(itemclass);
2232 itemcache_cost.erase(itemclass);
2233 cache_tile_mod_clear();
2234 }
2235
2236 5861589 void flushItemCache(bool justcost)
2237 {
2238 5861589 itemcache_cost.clear();
2239
2/2
✓ Branch 0 taken 5831552 times.
✓ Branch 1 taken 30037 times.
5861589 if(!justcost)
2240 30037 itemcache.clear();
2241
2/2
✓ Branch 0 taken 5831120 times.
✓ Branch 1 taken 432 times.
5831552 else if(replay_version_check(0,19))
2242 5831120 return;
2243
2244 30469 cache_tile_mod_clear();
2245
2246 //also fix the active subscreen if items were deleted -DD
2247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30469 times.
30469 if(game != NULL)
2248 {
2249 30469 verifyBothWeapons();
2250 30469 refresh_subscr_items();
2251 30469 }
2252 5861589 }
2253
2254 // This is used often, so it should be as direct as possible.
2255 237714092 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2256 {
2257 237714092 bool use_cost_cache = replay_version_check(19);
2258
2/2
✓ Branch 0 taken 196304690 times.
✓ Branch 1 taken 41409402 times.
237714092 if(jinx_check)
2259 {
2260
4/4
✓ Branch 0 taken 39648378 times.
✓ Branch 1 taken 1761024 times.
✓ Branch 2 taken 566304 times.
✓ Branch 3 taken 39082074 times.
41409402 if(!(HeroSwordClk() || HeroItemClk()))
2261 39082074 jinx_check = false; //not jinxed
2262 41409402 }
2263
2/2
✓ Branch 0 taken 113585 times.
✓ Branch 1 taken 237600507 times.
237714092 if(!Hero.BunnyClock())
2264 237600507 check_bunny = false; //not bunnied
2265
2/2
✓ Branch 0 taken 214190172 times.
✓ Branch 1 taken 23523920 times.
237714092 if(itemtype == itype_ring) checkmagic = true;
2266
4/4
✓ Branch 0 taken 235386764 times.
✓ Branch 1 taken 2327328 times.
✓ Branch 2 taken 211849481 times.
✓ Branch 3 taken 23242659 times.
472806232 if (!jinx_check && !check_bunny
2267
3/4
✓ Branch 0 taken 235386764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235092140 times.
✓ Branch 3 taken 294624 times.
235386764 && (use_cost_cache || itemtype != itype_ring))
2268 {
2269
4/4
✓ Branch 0 taken 171793023 times.
✓ Branch 1 taken 40351082 times.
✓ Branch 2 taken 171631357 times.
✓ Branch 3 taken 161666 times.
212144105 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2270 212144105 auto res = cache.find(itemtype);
2271
2272
2/2
✓ Branch 0 taken 196815949 times.
✓ Branch 1 taken 15328156 times.
212144105 if(res != cache.end())
2273 196815949 return res->second;
2274 15328156 }
2275
2276 40898143 int32_t result = -1;
2277 40898143 int32_t highestlevel = -1;
2278
2279
2/2
✓ Branch 0 taken 10469924608 times.
✓ Branch 1 taken 40898143 times.
10510822751 for(int32_t i=0; i<MAXITEMS; i++)
2280 {
2281
5/6
✓ Branch 0 taken 740217966 times.
✓ Branch 1 taken 9729706642 times.
✓ Branch 2 taken 16232093 times.
✓ Branch 3 taken 723985873 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16232093 times.
10469924608 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2282 {
2283
4/4
✓ Branch 0 taken 15725229 times.
✓ Branch 1 taken 506864 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 15716535 times.
16232093 if(checkmagic && itemtype != itype_magicring)
2284
2/2
✓ Branch 0 taken 15716377 times.
✓ Branch 1 taken 158 times.
15716535 if(!checkmagiccost(i))
2285 158 continue;
2286
6/6
✓ Branch 0 taken 14671645 times.
✓ Branch 1 taken 1560290 times.
✓ Branch 2 taken 106359 times.
✓ Branch 3 taken 1453931 times.
✓ Branch 4 taken 863949 times.
✓ Branch 5 taken 696341 times.
16231935 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 696341 times.
696341 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2288 696341 continue;
2289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15535594 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15535594 if(check_bunny && !checkbunny(i))
2290 continue;
2291
2292
2/2
✓ Branch 0 taken 153893 times.
✓ Branch 1 taken 15381701 times.
15535594 if(itemsbuf[i].fam_type >= highestlevel)
2293 {
2294 15381701 highestlevel = itemsbuf[i].fam_type;
2295 15381701 result=i;
2296 15381701 }
2297 15535594 }
2298 10469228109 }
2299
2300
3/4
✓ Branch 0 taken 38570815 times.
✓ Branch 1 taken 2327328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38570815 times.
40898143 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2301 {
2302
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 38566355 times.
38570815 if (use_cost_cache)
2303 {
2304
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 2192 times.
4460 if (!checkmagic)
2305 2192 itemcache[itemtype] = result;
2306
5/6
✓ Branch 0 taken 2192 times.
✓ Branch 1 taken 2268 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2188 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4460 if (checkmagic || result < 0 || checkmagiccost(result))
2307 4460 itemcache_cost[itemtype] = result;
2308 4460 }
2309 else
2310 {
2311 38566355 itemcache[itemtype] = result;
2312 }
2313 38570815 }
2314 40898143 return result;
2315 237714092 }
2316
2317 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2318 235830977 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2319 {
2320
2/4
✓ Branch 0 taken 235830977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 235830977 times.
235830977 if(itype < 0 || itype >= itype_max) return -1;
2321
1/2
✓ Branch 0 taken 235830977 times.
✗ Branch 1 not taken.
235830977 if(game->OverrideItems[itype] > -2)
2322 {
2323 auto ovid = game->OverrideItems[itype];
2324 if(ovid < 0 || ovid >= MAXITEMS)
2325 return -1;
2326 if(itemsbuf[ovid].family == itype)
2327 {
2328 if(itype == itype_magicring)
2329 checkmagic = false;
2330 else if(itype == itype_ring)
2331 checkmagic = true;
2332
2333 if(checkmagic && !checkmagiccost(ovid))
2334 return -1;
2335 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2336 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2337 return -1;
2338 return ovid;
2339 }
2340 }
2341 235830977 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2342
2/2
✓ Branch 0 taken 39526287 times.
✓ Branch 1 taken 196304690 times.
235830977 if(!jinx_check) //If not already a jinx-immune-only check...
2343 {
2344 //And the player IS jinxed...
2345
4/4
✓ Branch 0 taken 194886643 times.
✓ Branch 1 taken 1418047 times.
✓ Branch 2 taken 465068 times.
✓ Branch 3 taken 194421575 times.
196304690 if(HeroSwordClk() || HeroItemClk())
2346 {
2347 //Then do a jinx-immune-only check here
2348 1883115 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2349 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2350 //Should NOT need a compat rule, as this should always return -1 in old quests.
2351
2/2
✓ Branch 0 taken 523197 times.
✓ Branch 1 taken 1359918 times.
1883115 if(ret2 > -1) return ret2;
2352 1359918 }
2353 195781493 }
2354 235307780 return ret;
2355 235830977 }
2356
2357 19471445 int32_t current_item_power(int32_t itemtype)
2358 {
2359 19471445 int32_t result = current_item_id(itemtype,true);
2360
2/2
✓ Branch 0 taken 14106681 times.
✓ Branch 1 taken 5364764 times.
19471445 return (result<0) ? 0 : itemsbuf[result].power;
2361 }
2362
2363 11 int32_t heart_container_id()
2364 {
2365
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2366 {
2367
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2368 {
2369 11 return i;
2370 }
2371 308 }
2372 return -1;
2373 11 }
2374
2375 struct tilemod_cache_state_t
2376 {
2377
6/6
✓ Branch 0 taken 26147 times.
✓ Branch 1 taken 6027753 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6027751 times.
✓ Branch 4 taken 318 times.
✓ Branch 5 taken 6027433 times.
12081653 bool operator==(const tilemod_cache_state_t&) const = default;
2378
2379 bool valid;
2380 bool bunny_clock;
2381 bool superman;
2382 int shield;
2383 };
2384 tilemod_cache_state_t tilemod_cache_state;
2385 int32_t tilemod_cache_value;
2386
2387 31001 void cache_tile_mod_clear()
2388 {
2389 31001 tilemod_cache_state = {false};
2390 31001 }
2391
2392 6053900 int32_t item_tile_mod()
2393 {
2394 24215600 tilemod_cache_state_t state = {
2395 .valid = true,
2396 6053900 .bunny_clock = Hero.BunnyClock() != 0,
2397 6053900 .superman = Hero.superman,
2398 6053900 .shield = Hero.active_shield_id,
2399 };
2400
2/2
✓ Branch 0 taken 6027433 times.
✓ Branch 1 taken 26467 times.
6053900 if (tilemod_cache_state == state)
2401 6027433 return tilemod_cache_value;
2402
2403 26467 int32_t tile=0;
2404 26467 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2405
3/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21489 times.
✓ Branch 3 taken 4978 times.
26467 if(check_bombcost || game->get_bombs())
2406 {
2407 21489 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2408
3/4
✓ Branch 0 taken 20340 times.
✓ Branch 1 taken 1149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20340 times.
21489 if(itemid > -1 && checkbunny(itemid))
2409 20340 tile+=itemsbuf[itemid].ltm;
2410 21489 }
2411
2412
3/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6765 times.
✓ Branch 3 taken 19702 times.
26467 if(check_bombcost || game->get_sbombs())
2413 {
2414 6765 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2415
3/4
✓ Branch 0 taken 6759 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6759 times.
6765 if(itemid > -1 && checkbunny(itemid))
2416 6759 tile+=itemsbuf[itemid].ltm;
2417 6765 }
2418
2419
2/2
✓ Branch 0 taken 25610 times.
✓ Branch 1 taken 857 times.
26467 if(current_item(itype_clock))
2420 {
2421 857 int32_t itemid =
2422
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 get_qr(qr_HARDCODED_LITEM_LTMS)
2423 ? iClock
2424 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2425
2/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 857 times.
857 if(itemid > -1 && checkbunny(itemid))
2426 857 tile+=itemsbuf[itemid].ltm;
2427 857 }
2428
2429
2/2
✓ Branch 0 taken 20192 times.
✓ Branch 1 taken 6275 times.
26467 if(current_item(itype_key))
2430 {
2431 6275 int32_t itemid =
2432
1/2
✓ Branch 0 taken 6275 times.
✗ Branch 1 not taken.
6275 get_qr(qr_HARDCODED_LITEM_LTMS)
2433 ? iKey
2434 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2435
2/4
✓ Branch 0 taken 6275 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6275 times.
6275 if(itemid > -1 && checkbunny(itemid))
2436 6275 tile+=itemsbuf[itemid].ltm;
2437 6275 }
2438
2439
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 1478 times.
26467 if(current_item(itype_lkey))
2440 {
2441 1478 int32_t itemid =
2442
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 6 times.
1478 get_qr(qr_HARDCODED_LITEM_LTMS)
2443 ? iLevelKey
2444 6 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2445
2/4
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1478 times.
1478 if(itemid > -1 && checkbunny(itemid))
2446 1478 tile+=itemsbuf[itemid].ltm;
2447 1478 }
2448
2449
2/2
✓ Branch 0 taken 5912 times.
✓ Branch 1 taken 20555 times.
26467 if(current_item(itype_map))
2450 {
2451 20555 int32_t itemid =
2452
2/2
✓ Branch 0 taken 20553 times.
✓ Branch 1 taken 2 times.
20555 get_qr(qr_HARDCODED_LITEM_LTMS)
2453 ? iMap
2454 2 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2455
2/4
✓ Branch 0 taken 20555 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20555 times.
20555 if(itemid > -1 && checkbunny(itemid))
2456 20555 tile+=itemsbuf[itemid].ltm;
2457 20555 }
2458
2459
2/2
✓ Branch 0 taken 5698 times.
✓ Branch 1 taken 20769 times.
26467 if(current_item(itype_compass))
2460 {
2461 20769 int32_t itemid =
2462
2/2
✓ Branch 0 taken 20368 times.
✓ Branch 1 taken 401 times.
20769 get_qr(qr_HARDCODED_LITEM_LTMS)
2463 ? iCompass
2464 401 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2465
2/4
✓ Branch 0 taken 20769 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20769 times.
20769 if(itemid > -1 && checkbunny(itemid))
2466 20769 tile+=itemsbuf[itemid].ltm;
2467 20769 }
2468
2469
2/2
✓ Branch 0 taken 15499 times.
✓ Branch 1 taken 10968 times.
26467 if(current_item(itype_bosskey))
2470 {
2471 10968 int32_t itemid =
2472
1/2
✓ Branch 0 taken 10968 times.
✗ Branch 1 not taken.
10968 get_qr(qr_HARDCODED_LITEM_LTMS)
2473 ? iBossKey
2474 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2475
2/4
✓ Branch 0 taken 10968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10968 times.
10968 if(itemid > -1 && checkbunny(itemid))
2476 10968 tile+=itemsbuf[itemid].ltm;
2477 10968 }
2478
2479
2/2
✓ Branch 0 taken 13012 times.
✓ Branch 1 taken 13455 times.
26467 if(current_item(itype_magiccontainer))
2480 {
2481 13455 int32_t itemid =
2482
2/2
✓ Branch 0 taken 13001 times.
✓ Branch 1 taken 454 times.
13455 get_qr(qr_HARDCODED_LITEM_LTMS)
2483 ? iMagicC
2484 454 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2485
3/4
✓ Branch 0 taken 13455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 13438 times.
13455 if(itemid > -1 && checkbunny(itemid))
2486 13438 tile+=itemsbuf[itemid].ltm;
2487 13455 }
2488
2489
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 19306 times.
26467 if(current_item(itype_triforcepiece))
2490 {
2491 19306 int32_t itemid =
2492
1/2
✓ Branch 0 taken 19306 times.
✗ Branch 1 not taken.
19306 get_qr(qr_HARDCODED_LITEM_LTMS)
2493 ? iTriforce
2494 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2495
2/4
✓ Branch 0 taken 19306 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19306 times.
19306 if(itemid > -1 && checkbunny(itemid))
2496 19306 tile+=itemsbuf[itemid].ltm;
2497 19306 }
2498
2499
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<itype_max; i++)
2500 {
2501
2/2
✓ Branch 0 taken 13294592 times.
✓ Branch 1 taken 256512 times.
13551104 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2502 {
2503
2/2
✓ Branch 0 taken 5010 times.
✓ Branch 1 taken 251502 times.
256512 switch(i)
2504 {
2505 case itype_bomb:
2506 case itype_sbomb:
2507 case itype_clock:
2508 case itype_key:
2509 case itype_lkey:
2510 case itype_map:
2511 case itype_compass:
2512 case itype_bosskey:
2513 case itype_magiccontainer:
2514 case itype_triforcepiece:
2515 5010 continue; //already handled
2516 }
2517 251502 }
2518 13546094 int32_t itemid = current_item_id(i,false);
2519
2/2
✓ Branch 0 taken 13519627 times.
✓ Branch 1 taken 26467 times.
13546094 if(i == itype_shield)
2520 26467 itemid = getCurrentShield(false);
2521
2522
4/4
✓ Branch 0 taken 353604 times.
✓ Branch 1 taken 13192490 times.
✓ Branch 2 taken 919 times.
✓ Branch 3 taken 352685 times.
13546094 if(itemid < 0 || !checkbunny(itemid))
2523 13193409 continue;
2524
2525 352685 itemdata const& itm = itemsbuf[itemid];
2526
2527
2/2
✓ Branch 0 taken 328767 times.
✓ Branch 1 taken 23918 times.
352685 switch(itm.family)
2528 {
2529 case itype_shield:
2530
1/2
✓ Branch 0 taken 23918 times.
✗ Branch 1 not taken.
23918 if(itm.flags & ITEM_FLAG9) //active shield
2531 {
2532 if(!usingActiveShield(itemid))
2533 {
2534 tile+=itm.misc6; //'Inactive PTM'
2535 continue;
2536 }
2537 }
2538 23918 break;
2539 }
2540
2541 352685 tile+=itm.ltm;
2542 352685 }
2543
2544 26467 tilemod_cache_value = tile;
2545 26467 tilemod_cache_state = state;
2546 26467 return tile;
2547 6053900 }
2548
2549 6053900 int32_t bunny_tile_mod()
2550 {
2551
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6052030 times.
6053900 if(Hero.BunnyClock())
2552 {
2553 1870 return game->get_bunny_ltm();
2554 }
2555 6052030 return 0;
2556 6053900 }
2557
2558 // Hints are drawn on a separate layer to combo reveals.
2559 16332 void draw_lens_under(BITMAP *dest, bool layer)
2560 {
2561 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2562 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2563 //Lens flag 3: Don't show armos/chest/dive items
2564 //Lens flag 4: Show Raft Paths
2565 //Lens flag 5: Show Invisible Enemies
2566
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2567
2568 16332 int32_t strike_hint_table[11]=
2569 {
2570 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2571 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2572 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2573 };
2574
2575 // int32_t page = tmpscr->cpage;
2576 {
2577 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2578 // int32_t temptimer=0;
2579 16332 int32_t tempitem, tempweapon=0;
2580 16332 strike_hint=strike_hint_table[strike_hint_counter];
2581
2582
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2583 {
2584 490 strike_hint_timer=0;
2585 490 strike_hint_counter=((strike_hint_counter+1)%11);
2586 490 }
2587
2588 16332 ++strike_hint_timer;
2589
2590
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2591 {
2592 2874432 int32_t x = (i & 15) << 4;
2593 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2594 2874432 int32_t tempitemx=-16, tempitemy=-16;
2595 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2596
2597
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2598 {
2599 5748864 int32_t checkflag=0;
2600
2601
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2602 {
2603 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2604 2874432 }
2605 else
2606 {
2607 2874432 checkflag=tmpscr->sflag[i];
2608 }
2609
2610
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2611 {
2612
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2613 {
2614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2615 906 }
2616 else
2617 {
2618 192 checkflag = strike_hint;
2619 }
2620 1098 }
2621
2622
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2623 {
2624 case 0:
2625 case mfZELDA:
2626 case mfPUSHED:
2627 case mfENEMY0:
2628 case mfENEMY1:
2629 case mfENEMY2:
2630 case mfENEMY3:
2631 case mfENEMY4:
2632 case mfENEMY5:
2633 case mfENEMY6:
2634 case mfENEMY7:
2635 case mfENEMY8:
2636 case mfENEMY9:
2637 case mfSINGLE:
2638 case mfSINGLE16:
2639 case mfNOENEMY:
2640 case mfTRAP_H:
2641 case mfTRAP_V:
2642 case mfTRAP_4:
2643 case mfTRAP_LR:
2644 case mfTRAP_UD:
2645 case mfNOGROUNDENEMY:
2646 case mfNOBLOCKS:
2647 case mfSCRIPT1:
2648 case mfSCRIPT2:
2649 case mfSCRIPT3:
2650 case mfSCRIPT4:
2651 case mfSCRIPT5:
2652 case mfSCRIPT6:
2653 case mfSCRIPT7:
2654 case mfSCRIPT8:
2655 case mfSCRIPT9:
2656 case mfSCRIPT10:
2657 case mfSCRIPT11:
2658 case mfSCRIPT12:
2659 case mfSCRIPT13:
2660 case mfSCRIPT14:
2661 case mfSCRIPT15:
2662 case mfSCRIPT16:
2663 case mfSCRIPT17:
2664 case mfSCRIPT18:
2665 case mfSCRIPT19:
2666 case mfSCRIPT20:
2667 case mfPITHOLE:
2668 case mfPITFALLFLOOR:
2669 case mfLAVA:
2670 case mfICE:
2671 case mfICEDAMAGE:
2672 case mfDAMAGE1:
2673 case mfDAMAGE2:
2674 case mfDAMAGE4:
2675 case mfDAMAGE8:
2676 case mfDAMAGE16:
2677 case mfDAMAGE32:
2678 case mfFREEZEALL:
2679 case mfFREZEALLANSFFCS:
2680 case mfFREEZEFFCSOLY:
2681 case mfSCRITPTW1TRIG:
2682 case mfSCRITPTW2TRIG:
2683 case mfSCRITPTW3TRIG:
2684 case mfSCRITPTW4TRIG:
2685 case mfSCRITPTW5TRIG:
2686 case mfSCRITPTW6TRIG:
2687 case mfSCRITPTW7TRIG:
2688 case mfSCRITPTW8TRIG:
2689 case mfSCRITPTW9TRIG:
2690 case mfSCRITPTW10TRIG:
2691 case mfTROWEL:
2692 case mfTROWELNEXT:
2693 case mfTROWELSPECIALITEM:
2694 case mfSLASHPOT:
2695 case mfLIFTPOT:
2696 case mfLIFTORSLASH:
2697 case mfLIFTROCK:
2698 case mfLIFTROCKHEAVY:
2699 case mfDROPITEM:
2700 case mfSPECIALITEM:
2701 case mfDROPKEY:
2702 case mfDROPLKEY:
2703 case mfDROPCOMPASS:
2704 case mfDROPMAP:
2705 case mfDROPBOSSKEY:
2706 case mfSPAWNNPC:
2707 case mfSWITCHHOOK:
2708 case mfSIDEVIEWLADDER:
2709 case mfSIDEVIEWPLATFORM:
2710 case mfNOENEMYSPAWN:
2711 case mfENEMYALL:
2712 case mfNOMIRROR:
2713 case mfUNSAFEGROUND:
2714 case mf168:
2715 case mf169:
2716 case mf170:
2717 case mf171:
2718 case mf172:
2719 case mf173:
2720 case mf174:
2721 case mf175:
2722 case mf176:
2723 case mf177:
2724 case mf178:
2725 case mf179:
2726 case mf180:
2727 case mf181:
2728 case mf182:
2729 case mf183:
2730 case mf184:
2731 case mf185:
2732 case mf186:
2733 case mf187:
2734 case mf188:
2735 case mf189:
2736 case mf190:
2737 case mf191:
2738 case mf192:
2739 case mf193:
2740 case mf194:
2741 case mf195:
2742 case mf196:
2743 case mf197:
2744 case mf198:
2745 case mf199:
2746 case mf200:
2747 case mf201:
2748 case mf202:
2749 case mf203:
2750 case mf204:
2751 case mf205:
2752 case mf206:
2753 case mf207:
2754 case mf208:
2755 case mf209:
2756 case mf210:
2757 case mf211:
2758 case mf212:
2759 case mf213:
2760 case mf214:
2761 case mf215:
2762 case mf216:
2763 case mf217:
2764 case mf218:
2765 case mf219:
2766 case mf220:
2767 case mf221:
2768 case mf222:
2769 case mf223:
2770 case mf224:
2771 case mf225:
2772 case mf226:
2773 case mf227:
2774 case mf228:
2775 case mf229:
2776 case mf230:
2777 case mf231:
2778 case mf232:
2779 case mf233:
2780 case mf234:
2781 case mf235:
2782 case mf236:
2783 case mf237:
2784 case mf238:
2785 case mf239:
2786 case mf240:
2787 case mf241:
2788 case mf242:
2789 case mf243:
2790 case mf244:
2791 case mf245:
2792 case mf246:
2793 case mf247:
2794 case mf248:
2795 case mf249:
2796 case mf250:
2797 case mf251:
2798 case mf252:
2799 case mf253:
2800 case mf254:
2801 case mfEXTENDED:
2802 5706470 break;
2803
2804 case mfPUSHUD:
2805 case mfPUSHLR:
2806 case mfPUSH4:
2807 case mfPUSHU:
2808 case mfPUSHD:
2809 case mfPUSHL:
2810 case mfPUSHR:
2811 case mfPUSHUDNS:
2812 case mfPUSHLRNS:
2813 case mfPUSH4NS:
2814 case mfPUSHUNS:
2815 case mfPUSHDNS:
2816 case mfPUSHLNS:
2817 case mfPUSHRNS:
2818 case mfPUSHUDINS:
2819 case mfPUSHLRINS:
2820 case mfPUSH4INS:
2821 case mfPUSHUINS:
2822 case mfPUSHDINS:
2823 case mfPUSHLINS:
2824 case mfPUSHRINS:
2825
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2826
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2827 {
2828 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2829 }
2830
2831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2832
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2833 {
2834
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2835 {
2836
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2837 {
2838 case cPUSH_HEAVY:
2839 case cPUSH_HW:
2840 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2841 72 tempitemx=x, tempitemy=y;
2842
2843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2844 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2845
2846 72 break;
2847
2848 case cPUSH_HEAVY2:
2849 case cPUSH_HW2:
2850 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2851 63 tempitemx=x, tempitemy=y;
2852
2853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2854 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2855
2856 63 break;
2857 }
2858 1032 }
2859 2438 }
2860
2861 3148 break;
2862
2863 case mfWHISTLE:
2864
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2865 {
2866 tempitem=getItemID(itemsbuf,itype_whistle,1);
2867
2868 if(tempitem<0) break;
2869
2870 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2871 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2872 {
2873 tempitemx=x;
2874 tempitemy=y;
2875 }
2876
2877 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2878 }
2879
2880 2418 break;
2881
2882 //Why is this here?
2883 case mfFAIRY:
2884 case mfMAGICFAIRY:
2885 case mfALLFAIRY:
2886 if(hints)
2887 {
2888 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2889
2890 if(tempitem < 0) break;
2891
2892 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2893 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2894 {
2895 tempitemx=x;
2896 tempitemy=y;
2897 }
2898
2899 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2900 }
2901
2902 break;
2903
2904 case mfANYFIRE:
2905
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2906 {
2907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2908 252 }
2909 else
2910 {
2911 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2912
2913
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2914
2915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2916
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2917 {
2918 189 tempitemx=x;
2919 189 tempitemy=y;
2920 189 }
2921
2922 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2923 }
2924
2925 504 break;
2926
2927 case mfSTRONGFIRE:
2928 if(!hints)
2929 {
2930 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2931 }
2932 else
2933 {
2934 tempitem=getItemID(itemsbuf,itype_candle,2);
2935
2936 if(tempitem<0) break;
2937
2938 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2939 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2940 {
2941 tempitemx=x;
2942 tempitemy=y;
2943 }
2944
2945 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2946 }
2947
2948 break;
2949
2950 case mfMAGICFIRE:
2951 if(!hints)
2952 {
2953 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2954 }
2955 else
2956 {
2957 tempitem=getItemID(itemsbuf,itype_wand,1);
2958
2959 if(tempitem<0) break;
2960
2961 tempweapon=wFire;
2962
2963 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2964 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2965 {
2966 tempitemx=x;
2967 tempitemy=y;
2968 }
2969 else
2970 {
2971 tempweaponx=x;
2972 tempweapony=y;
2973 }
2974
2975 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2976 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2977 }
2978
2979 break;
2980
2981 case mfDIVINEFIRE:
2982 if(!hints)
2983 {
2984 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2985 }
2986 else
2987 {
2988 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2989
2990 if(tempitem<0) break;
2991
2992 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2993 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2994 {
2995 tempitemx=x;
2996 tempitemy=y;
2997 }
2998
2999 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3000 }
3001
3002 break;
3003
3004 case mfARROW:
3005
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3006 {
3007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3008 732 }
3009 else
3010 {
3011 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3012
3013
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3014
3015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3016
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3017 {
3018 61 tempitemx=x;
3019 61 tempitemy=y;
3020 61 }
3021
3022 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3023 }
3024
3025 814 break;
3026
3027 case mfSARROW:
3028 if(!hints)
3029 {
3030 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3031 }
3032 else
3033 {
3034 tempitem=getItemID(itemsbuf,itype_arrow,2);
3035
3036 if(tempitem<0) break;
3037
3038 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3039 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3040 {
3041 tempitemx=x;
3042 tempitemy=y;
3043 }
3044
3045 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3046 }
3047
3048 break;
3049
3050 case mfGARROW:
3051 if(!hints)
3052 {
3053 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3054 }
3055 else
3056 {
3057 tempitem=getItemID(itemsbuf,itype_arrow,3);
3058
3059 if(tempitem<0) break;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067
3068 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3069 }
3070
3071 break;
3072
3073 case mfBOMB:
3074
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3075 {
3076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3077 16 }
3078 else
3079 {
3080 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3081 17 tempweapon = wLitBomb;
3082
3083 //if (tempitem<0) break;
3084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3085
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3086 {
3087 12 tempweaponx=x;
3088 12 tempweapony=y;
3089 12 }
3090
3091 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3092 }
3093
3094 33 break;
3095
3096 case mfSBOMB:
3097
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3098 {
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3100 48 }
3101 else
3102 {
3103 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3104 //if (tempitem<0) break;
3105 48 tempweapon = wLitSBomb;
3106
3107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3108
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3109 {
3110 36 tempweaponx=x;
3111 36 tempweapony=y;
3112 36 }
3113
3114 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3115 }
3116
3117 96 break;
3118
3119 case mfARMOS_SECRET:
3120
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3121 {
3122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3123 12 }
3124 24 break;
3125
3126 case mfBRANG:
3127
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3128 {
3129 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3130 }
3131 else
3132 {
3133 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3134
3135
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3136
3137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3138
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3139 {
3140 4 tempitemx=x;
3141 4 tempitemy=y;
3142 4 }
3143
3144 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3145 }
3146
3147 5 break;
3148
3149 case mfMBRANG:
3150 if(!hints)
3151 {
3152 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3153 }
3154 else
3155 {
3156 tempitem=getItemID(itemsbuf,itype_brang,2);
3157
3158 if(tempitem<0) break;
3159
3160 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3161 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3162 {
3163 tempitemx=x;
3164 tempitemy=y;
3165 }
3166
3167 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3168 }
3169
3170 break;
3171
3172 case mfFBRANG:
3173 if(!hints)
3174 {
3175 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3176 }
3177 else
3178 {
3179 tempitem=getItemID(itemsbuf,itype_brang,3);
3180
3181 if(tempitem<0) break;
3182
3183 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3184 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3185 {
3186 tempitemx=x;
3187 tempitemy=y;
3188 }
3189
3190 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3191 }
3192
3193 break;
3194
3195 case mfWANDMAGIC:
3196 if(!hints)
3197 {
3198 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3199 }
3200 else
3201 {
3202 tempitem=getItemID(itemsbuf,itype_wand,1);
3203
3204 if(tempitem<0) break;
3205
3206 tempweapon=itemsbuf[tempitem].wpn3;
3207
3208 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3209 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3210 {
3211 tempitemx=x;
3212 tempitemy=y;
3213 }
3214 else
3215 {
3216 tempweaponx=x;
3217 tempweapony=y;
3218 --lens_hint_weapon[wMagic][4];
3219
3220 if(lens_hint_weapon[wMagic][4]<-8)
3221 {
3222 lens_hint_weapon[wMagic][4]=8;
3223 }
3224 }
3225
3226 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3227 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3228 }
3229
3230 break;
3231
3232 case mfREFMAGIC:
3233
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3234 {
3235 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3236 }
3237 else
3238 {
3239 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3240
3241
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3242
3243 16 tempweapon=ewMagic;
3244
3245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3246
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3247 {
3248 13 tempitemx=x;
3249 13 tempitemy=y;
3250 13 }
3251 else
3252 {
3253 3 tempweaponx=x;
3254 3 tempweapony=y;
3255
3256
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3257 {
3258 1 --lens_hint_weapon[ewMagic][4];
3259 1 }
3260 else
3261 {
3262 2 ++lens_hint_weapon[ewMagic][4];
3263 }
3264
3265
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3266 {
3267 lens_hint_weapon[ewMagic][2]=up;
3268 }
3269
3270
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3271 {
3272 2 lens_hint_weapon[ewMagic][2]=down;
3273 2 }
3274 }
3275
3276 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3277 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3278 }
3279
3280 16 break;
3281
3282 case mfREFFIREBALL:
3283
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3284 {
3285 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3286 }
3287 else
3288 {
3289 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3290
3291
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3292
3293 16 tempweapon=ewFireball;
3294
3295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 12 tempitemx=x;
3299 12 tempitemy=y;
3300 12 tempweaponx=x;
3301 12 tempweapony=y;
3302 12 ++lens_hint_weapon[ewFireball][3];
3303
3304
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3305 {
3306 1 lens_hint_weapon[ewFireball][3]=-8;
3307 1 lens_hint_weapon[ewFireball][4]=8;
3308 1 }
3309
3310
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3311 {
3312 8 ++lens_hint_weapon[ewFireball][4];
3313 8 }
3314 else
3315 {
3316 4 --lens_hint_weapon[ewFireball][4];
3317 }
3318 12 }
3319
3320 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3321 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3322 }
3323
3324 16 break;
3325
3326 case mfSWORD:
3327
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3328 {
3329 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3330 }
3331 else
3332 {
3333 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3334
3335
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3336
3337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3338
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3339 {
3340 5 tempitemx=x;
3341 5 tempitemy=y;
3342 5 }
3343
3344 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3345 }
3346
3347 7 break;
3348
3349 case mfWSWORD:
3350 if(!hints)
3351 {
3352 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3353 }
3354 else
3355 {
3356 tempitem=getItemID(itemsbuf,itype_sword,2);
3357
3358 if(tempitem<0) break;
3359
3360 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3361 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3362 {
3363 tempitemx=x;
3364 tempitemy=y;
3365 }
3366
3367 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3368 }
3369
3370 break;
3371
3372 case mfMSWORD:
3373 if(!hints)
3374 {
3375 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3376 }
3377 else
3378 {
3379 tempitem=getItemID(itemsbuf,itype_sword,3);
3380
3381 if(tempitem<0) break;
3382
3383 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3384 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3385 {
3386 tempitemx=x;
3387 tempitemy=y;
3388 }
3389
3390 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3391 }
3392
3393 break;
3394
3395 case mfXSWORD:
3396 if(!hints)
3397 {
3398 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3399 }
3400 else
3401 {
3402 tempitem=getItemID(itemsbuf,itype_sword,4);
3403
3404 if(tempitem<0) break;
3405
3406 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3407 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3408 {
3409 tempitemx=x;
3410 tempitemy=y;
3411 }
3412
3413 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3414 }
3415
3416 break;
3417
3418 case mfSWORDBEAM:
3419
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3420 {
3421 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3422 }
3423 else
3424 {
3425 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3426
3427
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3428
3429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3430
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3431 {
3432 11 tempitemx=x;
3433 11 tempitemy=y;
3434 11 }
3435
3436 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3437 }
3438
3439 16 break;
3440
3441 case mfWSWORDBEAM:
3442 if(!hints)
3443 {
3444 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3445 }
3446 else
3447 {
3448 tempitem=getItemID(itemsbuf,itype_sword,2);
3449
3450 if(tempitem<0) break;
3451
3452 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3453 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3454 {
3455 tempitemx=x;
3456 tempitemy=y;
3457 }
3458
3459 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3460 }
3461
3462 break;
3463
3464 case mfMSWORDBEAM:
3465 if(!hints)
3466 {
3467 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3468 }
3469 else
3470 {
3471 tempitem=getItemID(itemsbuf,itype_sword,3);
3472
3473 if(tempitem<0) break;
3474
3475 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3476 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3477 {
3478 tempitemx=x;
3479 tempitemy=y;
3480 }
3481
3482 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3483 }
3484
3485 break;
3486
3487 case mfXSWORDBEAM:
3488 if(!hints)
3489 {
3490 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3491 }
3492 else
3493 {
3494 tempitem=getItemID(itemsbuf,itype_sword,4);
3495
3496 if(tempitem<0) break;
3497
3498 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3499 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3500 {
3501 tempitemx=x;
3502 tempitemy=y;
3503 }
3504
3505 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3506 }
3507
3508 break;
3509
3510 case mfHOOKSHOT:
3511
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3512 {
3513 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3514 }
3515 else
3516 {
3517 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3518
3519
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3520
3521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3522
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3523 {
3524 12 tempitemx=x;
3525 12 tempitemy=y;
3526 12 }
3527
3528 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3529 }
3530
3531 17 break;
3532
3533 case mfWAND:
3534
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3535 {
3536 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3537 }
3538 else
3539 {
3540 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3541
3542
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3543
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3545
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3546 {
3547 28 tempitemx=x;
3548 28 tempitemy=y;
3549 28 }
3550
3551 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 }
3553
3554 35 break;
3555
3556 case mfHAMMER:
3557
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3558 {
3559 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3560 }
3561 else
3562 {
3563 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3564
3565
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3566
3567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3568
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3569 {
3570 13 tempitemx=x;
3571 13 tempitemy=y;
3572 13 }
3573
3574 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3575 }
3576
3577 17 break;
3578
3579 case mfARMOS_ITEM:
3580 case mfDIVE_ITEM:
3581
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3582 {
3583 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3584 2064 }
3585 2064 break;
3586
3587 case 16:
3588 case 17:
3589 case 18:
3590 case 19:
3591 case 20:
3592 case 21:
3593 case 22:
3594 case 23:
3595 case 24:
3596 case 25:
3597 case 26:
3598 case 27:
3599 case 28:
3600 case 29:
3601 case 30:
3602 case 31:
3603
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3605 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3606
3607 3618 break;
3608 case mfSECRETSNEXT:
3609 if(!hints)
3610 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3612
3613 break;
3614
3615 case mfSTRIKE:
3616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3617 {
3618 906 goto special;
3619 }
3620 else
3621 {
3622 break;
3623 }
3624
3625 28640 default: goto special;
3626
3627 special:
3628
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3629 {
3630
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3631 {
3632 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3633 4913 }
3634 6549 }
3635
3636 29546 break;
3637 }
3638 5748864 }
3639 2874432 }
3640
3641
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3642 {
3643
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3644 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3645
3646
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3647 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3648
3649
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3650 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3651
3652
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3653 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3654
3655
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3656 {
3657 43 showbombeddoor(dest, 0);
3658 43 }
3659
3660
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3661 {
3662 39 showbombeddoor(dest, 1);
3663 39 }
3664
3665
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3666 {
3667 showbombeddoor(dest, 2);
3668 }
3669
3670
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3671 {
3672 37 showbombeddoor(dest, 3);
3673 37 }
3674 8166 }
3675
3676
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3677 {
3678
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3679 {
3680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3681 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3682 1123 }
3683 else
3684 {
3685
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3686 {
3687 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3688 48 int32_t tempitemx=-16;
3689 48 int32_t tempitemy=-16;
3690
3691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3692
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3693 {
3694 24 tempitemx=tmpscr->stairx;
3695 24 tempitemy=tmpscr->stairy+playing_field_offset;
3696 24 }
3697
3698 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3699 48 }
3700 }
3701 2034 }
3702 }
3703 16332 }
3704
3705 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3706
3707 7997 void draw_lens_over()
3708 {
3709 // Oh, what the heck.
3710 static BITMAP *lens_scr = NULL;
3711 static int32_t last_width = -1;
3712 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3713
3714 // Only redraw the circle if the size has changed
3715
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3716 {
3717
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3718 {
3719 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3720 10 }
3721
3722 10 clear_to_color(lens_scr, BLACK);
3723 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3724 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3725 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3726 10 last_width=width;
3727 10 }
3728
3729 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3730 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3731 7997 }
3732
3733 //----------------------------------------------------------------
3734
3735 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3736 {
3737 //recreating a big bitmap every frame is highly sluggish.
3738
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3739 31111 clear_to_color(wavebuf, BLACK);
3740 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3741
3742 int32_t ofs;
3743 // int32_t amplitude=8;
3744 // int32_t wavelength=4;
3745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3746
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3747 31111 int32_t amp2=168;
3748
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3749 31111 int32_t i=frame%amp2;
3750
3751
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3752 {
3753
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3754 {
3755 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3756 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3757 }
3758 else
3759 {
3760 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3761 }
3762
3763
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3764 {
3765
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3766 {
3767 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3768 1338021888 }
3769 5226648 }
3770 5226648 }
3771 31111 }
3772
3773 4848 void draw_fuzzy(int32_t fuzz)
3774 // draws from right half of scrollbuf to framebuf
3775 {
3776 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3777 byte *start, *si, *di;
3778
3779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3780 fuzz = 1;
3781
3782 4848 xstep = 128%fuzz;
3783
3784
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3785 3838 xstep = fuzz-xstep;
3786
3787 4848 ystep = 112%fuzz;
3788
3789
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3790 3434 ystep = fuzz-ystep;
3791
3792 4848 firsty = 1;
3793
3794
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3795 {
3796 174932 start = &(scrollbuf->line[y][256]);
3797
3798
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3799 {
3800 1085952 si = start;
3801 1085952 di = &(framebuf->line[y+dy][0]);
3802 1085952 i = xstep;
3803 1085952 firstx = 1;
3804
3805
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3806 {
3807 278003712 *(di++) = *si;
3808
3809
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3810 {
3811
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3812 42668864 si += fuzz;
3813 else
3814 {
3815 1085952 si += fuzz-xstep;
3816 1085952 firstx = 0;
3817 }
3818
3819 43754816 i = 0;
3820 43754816 }
3821 278003712 }
3822 1085952 }
3823
3824
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3825 170084 y += fuzz;
3826 else
3827 {
3828 4848 y += ystep;
3829 4848 ystep = fuzz;
3830 4848 firsty = 0;
3831 }
3832 }
3833 4848 }
3834
3835 9287337 void updatescr(bool allowwavy)
3836 {
3837
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
9287337 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3838
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
9287337 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3839
3840
2/2
✓ Branch 0 taken 9260572 times.
✓ Branch 1 taken 26765 times.
9287337 if(toogam)
3841 {
3842 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3843 26765 }
3844
3845
1/2
✓ Branch 0 taken 9287337 times.
✗ Branch 1 not taken.
9287337 if(Showpal)
3846 dump_pal(framebuf);
3847
3848
2/2
✓ Branch 0 taken 8986105 times.
✓ Branch 1 taken 301232 times.
9287337 if(!Playing)
3849 301232 black_opening_count=0;
3850
3851
2/2
✓ Branch 0 taken 9213945 times.
✓ Branch 1 taken 73392 times.
9287337 if(black_opening_count<0) //shape is opening up
3852 {
3853 73392 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3854
3855
2/4
✓ Branch 0 taken 73392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73392 times.
73392 if(Advance||(!Paused))
3856 {
3857 73392 ++black_opening_count;
3858 73392 }
3859 73392 }
3860
2/2
✓ Branch 0 taken 9187809 times.
✓ Branch 1 taken 26136 times.
9213945 else if(black_opening_count>0) //shape is closing
3861 {
3862 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3863
3864
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3865 {
3866 26136 --black_opening_count;
3867 26136 }
3868 26136 }
3869
3870
3/4
✓ Branch 0 taken 9189317 times.
✓ Branch 1 taken 98020 times.
✓ Branch 2 taken 9189317 times.
✗ Branch 3 not taken.
9287337 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3871 {
3872 black_opening_shape = bosCIRCLE;
3873 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3874 refreshTints();
3875 refreshpal=true;
3876 }
3877
3878
2/2
✓ Branch 0 taken 9033135 times.
✓ Branch 1 taken 254202 times.
9287337 if(refreshpal)
3879 {
3880 254202 refreshpal=false;
3881 254202 RAMpal[253] = _RGB(0,0,0);
3882 254202 RAMpal[254] = _RGB(63,63,63);
3883 254202 hw_palette = &RAMpal;
3884 254202 update_hw_pal = true;
3885
3886 254202 create_rgb_table(&rgb_table, RAMpal, NULL);
3887 254202 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3888 254202 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3889
3890
2/2
✓ Branch 0 taken 65075712 times.
✓ Branch 1 taken 254202 times.
65329914 for(int32_t q=0; q<PAL_SIZE; q++)
3891 {
3892 65075712 trans_table2.data[0][q] = q;
3893 65075712 trans_table2.data[q][q] = q;
3894 65075712 }
3895 254202 }
3896
3897 9287337 bool clearwavy = (wavy <= 0);
3898
3899
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9279682 times.
9287337 if(wavy <= 0)
3900 {
3901 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3902 9279682 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3903 9279682 }
3904
3905 9287337 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3906
3907
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255976 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9287337 if(wavy && Playing && allowwavy)
3908 {
3909 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3910 31111 }
3911
3912
2/2
✓ Branch 0 taken 9279682 times.
✓ Branch 1 taken 7655 times.
9287337 if(clearwavy)
3913 9279682 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3914
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3915 7655 wavy--; // Wavy was set by a script. Decrement it.
3916
3917
5/6
✓ Branch 0 taken 8986105 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8726531 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9287337 if(Playing && msgpos && !screenscrolling)
3918 {
3919
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3920 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3921
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3922 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3923
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3924 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3925 259574 }
3926
3927 /*
3928 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3929 {
3930 BITMAP* subBmp = 0;
3931 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3932 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3933 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3934 destroy_bitmap(subBmp);
3935 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3936 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3937 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3938 }
3939 */
3940
3941
2/2
✓ Branch 0 taken 9246280 times.
✓ Branch 1 taken 41057 times.
9287337 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3942
3943
2/2
✓ Branch 0 taken 9250905 times.
✓ Branch 1 taken 36432 times.
9287337 if(nosubscr)
3944 {
3945 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3946 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3947 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3948 36432 }
3949
3950 //TODO: Optimize blit 'overcalls' -Gleeok
3951
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250905 times.
9287337 BITMAP *source = nosubscr ? panorama : wavybuf;
3952 9287337 blit(source,framebuf,0,0,0,0,256,224);
3953
3954 9287337 update_hw_screen();
3955 9287337 }
3956
3957 //----------------------------------------------------------------
3958
3959 static PALETTE syspal;
3960 int32_t onGUISnapshot()
3961 {
3962 char buf[200];
3963 int32_t num=0;
3964 do
3965 {
3966 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3967 }
3968 while(num<99999 && exists(buf));
3969
3970 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3971 InfoDialog("Error", "Failed to save snapshot").show();
3972
3973 return D_O_K;
3974 }
3975
3976 int32_t onNonGUISnapshot()
3977 {
3978 PALETTE temppal;
3979 get_palette(temppal);
3980 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3981
3982 char buf[200];
3983 int32_t num=0;
3984
3985 do
3986 {
3987 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3988 }
3989 while(num<99999 && exists(buf));
3990
3991 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3992 {
3993 BITMAP *b = create_bitmap_ex(8,256,168);
3994 clear_to_color(b,0);
3995 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3996 alleg4_save_bitmap(b, SnapshotScale, buf);
3997 destroy_bitmap(b);
3998 }
3999 else
4000 {
4001 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
4002 }
4003
4004 return D_O_K;
4005 }
4006
4007 int32_t onSnapshot()
4008 {
4009 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4010 {
4011 onGUISnapshot();
4012 }
4013 else
4014 {
4015 onNonGUISnapshot();
4016 }
4017
4018 return D_O_K;
4019 }
4020
4021 int32_t onSaveMapPic()
4022 {
4023 int32_t mapres2 = 0;
4024 char buf[200];
4025 int32_t num=0;
4026 mapscr tmpscr_b[2];
4027 mapscr tmpscr_c[6];
4028 BITMAP* _screen_draw_buffer = NULL;
4029 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4030 set_clip_state(_screen_draw_buffer,1);
4031
4032 for(int32_t i=0; i<6; ++i)
4033 {
4034 tmpscr_c[i] = tmpscr2[i];
4035 tmpscr2[i].zero_memory();
4036
4037 if(i>=2)
4038 {
4039 continue;
4040 }
4041
4042 tmpscr_b[i] = tmpscr[i];
4043 tmpscr[i].zero_memory();
4044 }
4045
4046 do
4047 {
4048 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4049 }
4050 while(num<99999 && exists(buf));
4051
4052 BITMAP* mappic = NULL;
4053
4054
4055 bool done=false, redraw=true;
4056
4057 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4058
4059 if(!mappic)
4060 {
4061 enter_sys_pal();
4062 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4063 exit_sys_pal();
4064 return D_O_K;;
4065 }
4066
4067 // draw the map
4068 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4069
4070 for(int32_t y=0; y<8; y++)
4071 {
4072 for(int32_t x=0; x<16; x++)
4073 {
4074 if(!displayOnMap(x, y))
4075 {
4076 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4077 }
4078 else
4079 {
4080 int32_t s = (y<<4) + x;
4081 loadscr2(1,s,-1);
4082
4083 for(int32_t i=0; i<6; i++)
4084 {
4085 if(tmpscr[1].layermap[i]<=0)
4086 continue;
4087
4088 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4089 }
4090
4091 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4092
4093 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4094
4095 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4096 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4097
4098 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4099
4100 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4101 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4102 {
4103 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4104 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4105 {
4106 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4107 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4108 }
4109 }
4110 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4111
4112 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4113
4114 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4115 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4116 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4117 {
4118 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4119 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4120 }
4121 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4122 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4123
4124 }
4125
4126 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4127 }
4128 }
4129
4130 for(int32_t i=0; i<6; ++i)
4131 {
4132 tmpscr2[i]=tmpscr_c[i];
4133
4134 if(i>=2)
4135 {
4136 continue;
4137 }
4138
4139 tmpscr[i]=tmpscr_b[i];
4140 }
4141
4142 save_bitmap(buf,mappic,RAMpal);
4143 destroy_bitmap(mappic);
4144 destroy_bitmap(_screen_draw_buffer);
4145 return D_O_K;
4146 }
4147
4148 14 void f_Quit(int32_t type)
4149 {
4150
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4151 return;
4152
4153 14 bool from_menu = is_sys_pal;
4154
4155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4156 {
4157 14 music_pause();
4158 14 pause_all_sfx();
4159 14 sys_mouse();
4160 14 }
4161 14 enter_sys_pal();
4162 14 clear_keybuf();
4163
4164
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4165 13 replay_poll();
4166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4167 14 replay_peek_quit();
4168
4169
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4170 switch(type)
4171 {
4172 case qQUIT:
4173 onQuit();
4174 break;
4175
4176 case qRESET:
4177 onReset();
4178 break;
4179
4180 case qEXIT:
4181 onExit();
4182 break;
4183 }
4184
4185
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4186 {
4187 14 kill_sfx();
4188 14 music_stop();
4189 14 exit_sys_pal();
4190 14 update_hw_screen();
4191 14 }
4192 else
4193 {
4194 exit_sys_pal();
4195 if(!from_menu)
4196 {
4197 music_resume();
4198 resume_all_sfx();
4199 }
4200 }
4201
4202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4203 14 game_mouse();
4204 14 eat_buttons();
4205
4206 14 zc_readrawkey(KEY_ESC);
4207
4208 14 zc_readrawkey(KEY_ENTER);
4209 14 }
4210
4211 //----------------------------------------------------------------
4212
4213 int32_t onNoWalls()
4214 {
4215 cheats_enqueue(Cheat::Walls);
4216 return D_O_K;
4217 }
4218
4219 int32_t onIgnoreSideview()
4220 {
4221 cheats_enqueue(Cheat::IgnoreSideView);
4222 return D_O_K;
4223 }
4224
4225 9287211 int32_t input_idle(bool checkmouse)
4226 {
4227 static int32_t mx, my, mz, mb;
4228
4229
4/6
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461754 times.
✓ Branch 3 taken 6825457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461754 times.
11748965 if(keypressed() || zc_key_pressed() ||
4230
4/8
✓ Branch 0 taken 2461754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461754 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461754 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461754 times.
✗ Branch 7 not taken.
2461754 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4231 {
4232 6825457 idle_count = 0;
4233
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6825457 times.
6825457 if(active_count < MAX_ACTIVE)
4235 {
4236 6825457 ++active_count;
4237 6825457 }
4238 6825457 }
4239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461754 times.
2461754 else if(idle_count < MAX_IDLE)
4240 {
4241 2461754 ++idle_count;
4242 2461754 active_count = 0;
4243 2461754 }
4244
4245 9287211 mx = mouse_x;
4246 9287211 my = mouse_y;
4247 9287211 mz = mouse_z;
4248 9287211 mb = mouse_b;
4249
4250 9287211 return idle_count;
4251 }
4252
4253 int32_t onGoFast()
4254 {
4255 cheats_enqueue(Cheat::Fast);
4256 return D_O_K;
4257 }
4258
4259 int32_t onKillCheat()
4260 {
4261 cheats_enqueue(Cheat::Kill);
4262 return D_O_K;
4263 }
4264
4265 int32_t onSecretsCheat()
4266 {
4267 cheats_enqueue(Cheat::TrigSecrets);
4268 return D_O_K;
4269 }
4270 int32_t onSecretsCheatPerm()
4271 {
4272 cheats_enqueue(Cheat::TrigSecretsPerm);
4273 return D_O_K;
4274 }
4275
4276 int32_t onShowLayer0()
4277 {
4278 show_layer_0 = !show_layer_0;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayer1()
4282 {
4283 show_layer_1 = !show_layer_1;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayer2()
4287 {
4288 show_layer_2 = !show_layer_2;
4289 return D_O_K;
4290 }
4291 int32_t onShowLayer3()
4292 {
4293 show_layer_3 = !show_layer_3;
4294 return D_O_K;
4295 }
4296 int32_t onShowLayer4()
4297 {
4298 show_layer_4 = !show_layer_4;
4299 return D_O_K;
4300 }
4301 int32_t onShowLayer5()
4302 {
4303 show_layer_5 = !show_layer_5;
4304 return D_O_K;
4305 }
4306 int32_t onShowLayer6()
4307 {
4308 show_layer_6 = !show_layer_6;
4309 return D_O_K;
4310 }
4311 int32_t onShowLayerO()
4312 {
4313 show_layer_over=!show_layer_over;
4314 return D_O_K;
4315 }
4316 int32_t onShowLayerP()
4317 {
4318 show_layer_push=!show_layer_push;
4319 return D_O_K;
4320 }
4321 int32_t onShowLayerS()
4322 {
4323 show_sprites=!show_sprites;
4324 return D_O_K;
4325 }
4326 int32_t onShowLayerF()
4327 {
4328 show_ffcs=!show_ffcs;
4329 return D_O_K;
4330 }
4331 int32_t onShowLayerW()
4332 {
4333 show_walkflags=!show_walkflags;
4334 if(show_walkflags)
4335 show_effectflags = false;
4336 return D_O_K;
4337 }
4338 int32_t onShowLayerE()
4339 {
4340 show_effectflags=!show_effectflags;
4341 if(show_effectflags)
4342 show_walkflags = false;
4343 return D_O_K;
4344 }
4345 int32_t onShowFFScripts()
4346 {
4347 show_ff_scripts=!show_ff_scripts;
4348 return D_O_K;
4349 }
4350 int32_t onShowHitboxes()
4351 {
4352 show_hitboxes=!show_hitboxes;
4353 return D_O_K;
4354 }
4355 int32_t onShowInfoOpacity()
4356 {
4357 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4358 zc_set_config("zc","debug_info_opacity",info_opacity);
4359 return D_O_K;
4360 }
4361
4362 int32_t onLightSwitch()
4363 {
4364 cheats_enqueue(Cheat::Light);
4365 return D_O_K;
4366 }
4367
4368 int32_t onGoTo();
4369 int32_t onGoToComplete();
4370
4371 9287211 bool handle_close_btn_quit()
4372 {
4373
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(close_button_quit)
4374 {
4375 close_button_quit=false;
4376 f_Quit(qEXIT);
4377 }
4378 9287211 return (exiting_program = Quit==qEXIT);
4379 }
4380
4381 9287211 void syskeys()
4382 {
4383 9287211 update_system_keys();
4384
4385 int32_t oldtitle_version;
4386
4387 9287211 poll_joystick();
4388
4389 9287211 handle_close_btn_quit();
4390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(Quit == qEXIT) return;
4391
4392
2/10
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9287211 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9287211 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4393 {
4394 System();
4395 }
4396
4397 9287211 mouse_down=gui_mouse_b();
4398
4399
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F1))
4400 {
4401 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4402 {
4403 halt=!halt;
4404 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4405 }
4406 else
4407 {
4408 Throttlefps=!Throttlefps;
4409 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4410 }
4411 }
4412
4413
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F2))
4414 {
4415 ShowFPS=!ShowFPS;
4416 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4417 }
4418
4419
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4420
4421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(zc_read_system_key(KEY_F4) && Playing)
4422 {
4423 Paused=true;
4424 Advance=true;
4425 }
4426
4427
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F6)) onTryQuit();
4428
4429 #ifndef ALLEGRO_MACOSX
4430
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4431
4432
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4433 #else
4434 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4435
4436 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4437 #endif
4438
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9287211 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4439
4440
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if (zc_read_system_key(KEY_F12))
4441 {
4442 onSnapshot();
4443 }
4444
4445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(debug_enabled && zc_read_system_key(KEY_TAB))
4446 set_debug(!get_debug());
4447
4448
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(CheatModifierKeys())
4449 {
4450 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4451 {
4452 if(!bindable_cheat(c))
4453 continue;
4454 if(get_debug() || cheat >= cheat_lvl(c))
4455 {
4456 if(checkcheat(c))
4457 cheats_hit_bind(c);
4458 }
4459 }
4460 }
4461
4462
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(volkeys)
4463 {
4464 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4465
4466 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4467
4468 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4469
4470 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4471 }
4472
4473
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9287211 if(!get_debug() || !SystemKeys || replay_is_replaying())
4474 9287211 goto bottom;
4475
4476 if(zc_readkey(KEY_D))
4477 {
4478 details = !details;
4479 rectfill(screen,0,0,319,7,BLACK);
4480 rectfill(screen,0,8,31,239,BLACK);
4481 rectfill(screen,288,8,319,239,BLACK);
4482 rectfill(screen,32,232,287,239,BLACK);
4483 }
4484
4485 if(zc_readkey(KEY_P)) Paused=!Paused;
4486
4487 //if(zc_readkey(KEY_P)) centerHero();
4488 if(zc_readkey(KEY_A))
4489 {
4490 Paused=true;
4491 Advance=true;
4492 }
4493
4494 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4495 #ifndef ALLEGRO_MACOSX
4496 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4497
4498 if(zc_readkey(KEY_F7))
4499 {
4500 Matrix(ss_speed, ss_density, 0);
4501 game_pal();
4502 }
4503 #else
4504 // The reason these are different on Mac in the first place is that
4505 // the OS doesn't let us use F9 and F10...
4506 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4507
4508 if(zc_readkey(KEY_F9))
4509 {
4510 Matrix(ss_speed, ss_density, 0);
4511 game_pal();
4512 }
4513 #endif
4514 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4515 {
4516 //change containers
4517 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4518 {
4519 //magic containers
4520 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4521 {
4522 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4523 }
4524 else
4525 {
4526 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4527 }
4528 }
4529 else
4530 {
4531 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4532 {
4533 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4534 }
4535 else
4536 {
4537 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4538 }
4539 }
4540 }
4541
4542 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4543 {
4544 //change containers
4545 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4546 {
4547 //magic containers
4548 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4549 {
4550 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4551 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4552 //heart containers
4553 }
4554 else
4555 {
4556 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4557 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4558 }
4559 }
4560 else
4561 {
4562 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4563 {
4564 game->set_magic(zc_max(game->get_magic()-1,0));
4565 }
4566 else
4567 {
4568 game->set_life(zc_max(game->get_life()-1,0));
4569 }
4570 }
4571 }
4572
4573 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4574
4575 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4576
4577 verifyBothWeapons();
4578
4579 bottom:
4580
4581
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(input_idle(true) > after_time())
4582 {
4583 Matrix(ss_speed, ss_density, 0);
4584 game_pal();
4585 }
4586 9287211 }
4587
4588 708292 void checkQuitKeys()
4589 {
4590 #ifndef ALLEGRO_MACOSX
4591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708292 times.
708292 if(key[KEY_F9]) f_Quit(qRESET);
4592
4593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708292 times.
708292 if(key[KEY_F10]) f_Quit(qEXIT);
4594 #else
4595 if(key[KEY_F7]) f_Quit(qRESET);
4596
4597 if(key[KEY_F8]) f_Quit(qEXIT);
4598 #endif
4599 708292 }
4600
4601 9287211 bool CheatModifierKeys()
4602 {
4603 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4604 // to trigger cheats.
4605
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if (replay_is_replaying())
4606 9287211 return false;
4607
4608 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4609 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4610 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4611 {
4612 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4613 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4614 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4615 {
4616 return true;
4617 }
4618 }
4619 return false;
4620 9287211 }
4621
4622 //99:05:54, for some reason?
4623 #define OLDMAXTIME 21405240
4624 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4625 #define MAXTIME 1944000000
4626
4627 9287337 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4628 {
4629
1/2
✓ Branch 0 taken 9287337 times.
✗ Branch 1 not taken.
9287337 if(zcmusic!=NULL)
4630 {
4631 zcmusic_poll();
4632 }
4633 9287337 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4634
4635 9287337 updatescr(allowwavy);
4636
4637 9287337 Advance=false;
4638
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9287337 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9287337 times.
9287337 while(Paused && !Advance && !Quit)
4639 {
4640 // have to call this, otherwise we'll get an infinite loop
4641 syskeys();
4642 if(allowF6Script)
4643 {
4644 FFCore.runF6Engine();
4645 }
4646 zc_throttle_fps();
4647
4648 #ifdef _WIN32
4649
4650 if(use_dwm_flush)
4651 {
4652 do_DwmFlush();
4653 }
4654
4655 #endif
4656
4657 // to keep music playing
4658 if(zcmusic!=NULL)
4659 {
4660 zcmusic_poll();
4661 }
4662
4663 update_hw_screen();
4664 }
4665
4666
2/2
✓ Branch 0 taken 9287225 times.
✓ Branch 1 taken 112 times.
9287337 if(Quit)
4667 112 return;
4668
4669
3/4
✓ Branch 0 taken 8986096 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8986096 times.
9287225 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4670 8986096 game->change_time(1);
4671
4672 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4673
4674 9287225 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4675
2/2
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 9266797 times.
9287225 if (replay_version_check(0, 16))
4676 9266797 should_reset_down_state = replay_version_check(11, 16);
4677
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2337545 times.
9287225 if (should_reset_down_state)
4678 {
4679
2/2
✓ Branch 0 taken 42075810 times.
✓ Branch 1 taken 2337545 times.
44413355 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4680 42075810 down_control_states[i] = raw_control_state[i];
4681 2337545 }
4682
4683
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_active())
4684 {
4685
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016762 times.
9287211 if (replay_version_check(3))
4686 8016762 replay_poll();
4687
4688
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2341113 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9287211 if (replay_version_check(11) || replay_version_check(6, 8))
4689 2441648 replay_peek_input();
4690 9287211 }
4691
4692 9287225 load_control_called_this_frame = false;
4693
4694 9287225 poll_keyboard();
4695 9287225 update_keys();
4696
4697 9287225 ++frame;
4698
4699
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_replaying())
4700 9287211 replay_do_cheats();
4701 9287225 syskeys();
4702
4703 // The mouse variables can change from the mouse thread at anytime during a frame,
4704 // so save the result at the start so that replaying is consistent.
4705 9287225 script_mouse_x = gui_mouse_x();
4706 9287225 script_mouse_y = gui_mouse_y();
4707 9287225 script_mouse_z = mouse_z;
4708 9287225 script_mouse_b = mouse_b;
4709
4710 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4711 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4712 // approach here means it doesn't matter which call adds the cheat.
4713 9287225 cheats_execute_queued();
4714
4715
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_replaying())
4716 9287211 replay_peek_quit();
4717
2/2
✓ Branch 0 taken 9287211 times.
✓ Branch 1 taken 14 times.
9287225 if (GameFlags & GAMEFLAG_TRYQUIT)
4718 14 replay_step_quit(0);
4719
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9284291 times.
9287225 if(allowF6Script)
4720 9284291 FFCore.runF6Engine();
4721
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 9286924 times.
9287225 if (Quit)
4722 301 replay_step_quit(Quit);
4723 // Someday... maybe install a Turbo button here?
4724 9287225 zc_throttle_fps();
4725
4726 #ifdef _WIN32
4727
4728 if(use_dwm_flush)
4729 {
4730 do_DwmFlush();
4731 }
4732
4733 #endif
4734
4735 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4736
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9218467 times.
9287225 if(sfxcleanup)
4737 9218467 sfx_cleanup();
4738
4739 9287225 jit_poll();
4740
4741 #ifdef __EMSCRIPTEN__
4742 // Yield the main thread back to the browser occasionally.
4743 if (is_headless())
4744 {
4745 static int rate = 10000;
4746 static int force_yield = rate;
4747 if (force_yield++ >= rate)
4748 {
4749 force_yield = 0;
4750 emscripten_sleep(0);
4751 }
4752 }
4753 #endif
4754
4755
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
9287225 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287225 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287225 if (zqtesting_mode && test_mode_auto_restart)
4757 {
4758 static auto last_write_time = fs::last_write_time(qstpath);
4759 static auto last_check = std::chrono::system_clock::now();
4760
4761 if (std::chrono::system_clock::now() - last_check > 200ms)
4762 {
4763 last_check = std::chrono::system_clock::now();
4764 auto write_time = fs::last_write_time(qstpath);
4765 if (last_write_time != write_time)
4766 {
4767 last_write_time = write_time;
4768 disableClickToFreeze = false;
4769 Quit = qRESET;
4770 replay_quit();
4771 }
4772 }
4773 }
4774 9287337 }
4775
4776 101 void zapout()
4777 {
4778 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4779 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4780
4781 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4782 101 script_drawing_commands.Clear();
4783
4784 // zap out
4785
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4786 {
4787 2424 draw_fuzzy(i);
4788 2424 advanceframe(true);
4789
4790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4791 {
4792 break;
4793 }
4794 2424 }
4795 101 }
4796
4797 101 void zapin()
4798 {
4799 101 FFCore.warpScriptCheck();
4800 101 draw_screen(tmpscr);
4801 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4802 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4803 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4804
4805 // zap out
4806 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4807
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4808 {
4809 2424 draw_fuzzy(i);
4810 2424 advanceframe(true);
4811
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4813 {
4814 break;
4815 }
4816 2424 }
4817 101 }
4818
4819
4820 65 void wavyout(bool showhero)
4821 {
4822 65 draw_screen(tmpscr, showhero);
4823 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4824
4825 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4826 65 clear_to_color(wavebuf,0);
4827 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4828
4829 static PALETTE wavepal;
4830
4831 int32_t ofs;
4832 65 int32_t amplitude=8;
4833
4834 65 int32_t wavelength=4;
4835 65 double palpos=0, palstep=4, palstop=126;
4836
4837 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4838
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4839 {
4840
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4841 {
4842 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4843 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4844 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4845 698880 }
4846
4847 2730 palpos+=palstep;
4848
4849
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4850 {
4851 2730 hw_palette = &wavepal;
4852 2730 update_hw_pal = true;
4853 2730 }
4854 else
4855 {
4856 hw_palette = &RAMpal;
4857 update_hw_pal = true;
4858 }
4859
4860
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4861 {
4862
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4863 {
4864 117411840 ofs=0;
4865
4866
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4867 {
4868 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4869 28654080 }
4870
4871 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4872 117411840 }
4873 458640 }
4874
4875 2730 advanceframe(true);
4876
4877 // animate_combos();
4878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4879 break;
4880 2730 }
4881
4882 65 destroy_bitmap(wavebuf);
4883 65 }
4884
4885 65 void wavyin()
4886 {
4887 65 draw_screen(tmpscr);
4888 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4889
4890 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4891 65 clear_to_color(wavebuf,0);
4892 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4893
4894 static PALETTE wavepal;
4895
4896 //Breaks dark rooms.
4897 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4898 /*
4899 loadfullpal();
4900 loadlvlpal(DMaps[currdmap].color);
4901 ringcolor(false);
4902 */
4903 65 refreshpal=false;
4904 int32_t ofs;
4905 65 int32_t amplitude=8;
4906 65 int32_t wavelength=4;
4907 65 double palpos=168, palstep=4, palstop=126;
4908
4909 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4910
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4911 {
4912
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4913 {
4914 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4915 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4916 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4917 698880 }
4918
4919 2730 palpos-=palstep;
4920
4921
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4922 {
4923 2730 hw_palette = &wavepal;
4924 2730 update_hw_pal = true;
4925 2730 }
4926 else
4927 {
4928 hw_palette = &RAMpal;
4929 update_hw_pal = true;
4930 }
4931
4932
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4933 {
4934
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4935 {
4936 117411840 ofs=0;
4937
4938
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4939 {
4940 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4941 29352960 }
4942
4943 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4944 117411840 }
4945 458640 }
4946
4947 2730 advanceframe(true);
4948 // animate_combos();
4949
4950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4951 break;
4952 2730 }
4953
4954 65 destroy_bitmap(wavebuf);
4955 65 }
4956
4957 2168 void blackscr(int32_t fcnt,bool showsubscr)
4958 {
4959 2168 reset_pal_cycling();
4960 2168 script_drawing_commands.Clear();
4961
4962 2168 FFCore.warpScriptCheck();
4963 2168 bool showtime = game->should_show_time();
4964
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4965 {
4966 64970 clear_bitmap(framebuf);
4967
4968
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4969 {
4970 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4971
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4972 {
4973 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4974 750 }
4975 39890 }
4976
4977 64970 advanceframe(true);
4978
4979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4980 break;
4981
4982 64970 --fcnt;
4983 }
4984 2168 }
4985
4986 1013 void openscreen(int32_t shape)
4987 {
4988 1013 reset_pal_cycling();
4989 1013 black_opening_count=0;
4990
4991
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1013 if(COOLSCROLL || shape>-1)
4992 {
4993 913 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4994 913 return;
4995 }
4996 else
4997 {
4998 100 Hero.setDontDraw(true);
4999 100 show_subscreen_dmap_dots=false;
5000 100 show_subscreen_numbers=false;
5001 // show_subscreen_items=false;
5002 100 show_subscreen_life=false;
5003 }
5004
5005 100 int32_t x=128;
5006
5007 100 FFCore.warpScriptCheck();
5008
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
5009 {
5010 8000 draw_screen(tmpscr);
5011 //? draw_screen already draws the subscreen -DD
5012 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5013 8000 x=128-(((i*128/80)/8)*8);
5014
5015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
5016 {
5017 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5018 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5019 8000 }
5020
5021 8000 advanceframe(true);
5022
5023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5024 {
5025 break;
5026 }
5027 8000 }
5028
5029 100 Hero.setDontDraw(false);
5030 100 show_subscreen_items=true;
5031 100 show_subscreen_dmap_dots=true;
5032 1013 }
5033
5034 void closescreen(int32_t shape)
5035 {
5036 reset_pal_cycling();
5037 black_opening_count=0;
5038
5039 if(COOLSCROLL || shape>-1)
5040 {
5041 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5042 return;
5043 }
5044 else
5045 {
5046 Hero.setDontDraw(true);
5047 show_subscreen_dmap_dots=false;
5048 show_subscreen_numbers=false;
5049 // show_subscreen_items=false;
5050 show_subscreen_life=false;
5051 }
5052
5053 int32_t x=128;
5054
5055 FFCore.warpScriptCheck();
5056 for(int32_t i=79; i>=0; --i)
5057 {
5058 draw_screen(tmpscr);
5059 //? draw_screen already draws the subscreen -DD
5060 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5061 x=128-(((i*128/80)/8)*8);
5062
5063 if(x>0)
5064 {
5065 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5066 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5067 }
5068
5069 advanceframe(true);
5070
5071 if(Quit)
5072 {
5073 break;
5074 }
5075 }
5076
5077 Hero.setDontDraw(false);
5078 show_subscreen_items=true;
5079 show_subscreen_dmap_dots=true;
5080 }
5081
5082 179 int32_t TriforceCount()
5083 {
5084 179 int32_t c=0;
5085
5086
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5087
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5088 1044 ++c;
5089
5090 179 return c;
5091 }
5092
5093 int32_t onCustomGame()
5094 {
5095 int32_t file = getsaveslot();
5096
5097 if(file < 0)
5098 return D_O_K;
5099
5100 bool ret = (custom_game(file)!=0);
5101 return ret ? D_CLOSE : D_O_K;
5102 }
5103
5104 int32_t onContinue()
5105 {
5106 return D_CLOSE;
5107 }
5108
5109 int32_t onEsc() // Unused?? -L
5110 {
5111 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5112 }
5113
5114 int32_t onThrottleFPS()
5115 {
5116 Throttlefps = !Throttlefps;
5117 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5118 return D_O_K;
5119 }
5120
5121 int32_t onWinPosSave()
5122 {
5123 SaveWinPos = !SaveWinPos;
5124 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5125 return D_O_K;
5126 }
5127 int32_t onIntegerScaling()
5128 {
5129 scaleForceInteger = !scaleForceInteger;
5130 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5131 return D_O_K;
5132 }
5133 int32_t onStretchGame()
5134 {
5135 stretchGame = !stretchGame;
5136 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5137 return D_O_K;
5138 }
5139
5140 int32_t onClickToFreeze()
5141 {
5142 ClickToFreeze = !ClickToFreeze;
5143 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5144 return D_O_K;
5145 }
5146
5147 int32_t OnSaveZCConfig()
5148 {
5149 if(jwin_alert3(
5150 "Save Configuration",
5151 "Are you sure that you wish to save your present configuration settings?",
5152 "This will overwrite your prior settings!",
5153 NULL,
5154 "&Yes",
5155 "&No",
5156 NULL,
5157 'y',
5158 'n',
5159 0,
5160 get_zc_font(font_lfont)) == 1)
5161 {
5162 save_game_configs();
5163 return D_O_K;
5164 }
5165 else return D_O_K;
5166 }
5167
5168 int32_t OnnClearQuestDir()
5169 {
5170 auto current_path = fs::current_path() / "quests";
5171 if(jwin_alert3(
5172 "Clear Current Directory Cache",
5173 "Are you sure that you wish to reset where ZC Player looks for quests?",
5174 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
5175 NULL,
5176 "&Yes",
5177 "&No",
5178 NULL,
5179 'y',
5180 'n',
5181 0,
5182 get_zc_font(font_lfont)) == 1)
5183 {
5184 zc_set_config("zeldadx","quest_dir","quests");
5185 flush_config_file();
5186 strcpy(qstdir,"quests");
5187 #ifdef __EMSCRIPTEN__
5188 em_sync_fs();
5189 #endif
5190 return D_O_K;
5191 }
5192 else return D_O_K;
5193 }
5194
5195
5196 int32_t onConsoleZASM()
5197 {
5198 if ( !zasm_debugger )
5199 {
5200 AlertDialog("WARNING: ZASM Debugger",
5201 "Enabling this will open the ZASM Debugger Console"
5202 "\nThis will likely grind ZC to a halt with lag."
5203 "\nTo make any use of this, it is suggested that you read"
5204 "\nthe documentation for 'void Breakpoint(char[] string);'"
5205 " in 'ZScript_Additions.txt'"
5206 "\nThis is not recommended for normal users,"
5207 " and is only intended for ZC developers,"
5208 "\nor quest developers coding directly in ZASM"
5209 "\nAre you sure that you wish to open the ZASM Debugger?",
5210 [&](bool ret,bool)
5211 {
5212 if(ret)
5213 {
5214 FFCore.ZASMPrint(true);
5215 }
5216 }).show();
5217 return D_O_K;
5218 }
5219 else
5220 {
5221 FFCore.ZASMPrint(false);
5222 return D_O_K;
5223 }
5224 }
5225
5226
5227 int32_t onConsoleZScript()
5228 {
5229 if ( !zscript_debugger )
5230 {
5231 AlertDialog("ZScript Debugger",
5232 "Enabling this will open the ZScript Debugger Console"
5233 "\nThis will display any messages logged by scripts,"
5234 " including script errors."
5235 "\nAre you sure that you wish to open the ZScript Debugger?",
5236 [&](bool ret,bool)
5237 {
5238 if(ret)
5239 {
5240 FFCore.ZScriptConsole(true);
5241 }
5242 }).show();
5243 return D_O_K;
5244 }
5245 else
5246 {
5247 FFCore.ZScriptConsole(false);
5248 return D_O_K;
5249 }
5250 }
5251
5252 int32_t onClrConsoleOnReload()
5253 {
5254 clearConsoleOnReload = !clearConsoleOnReload;
5255 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5256 return D_O_K;
5257 }
5258 int32_t onClrConsoleOnLoad()
5259 {
5260 clearConsoleOnLoad = !clearConsoleOnLoad;
5261 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5262 return D_O_K;
5263 }
5264
5265
5266 int32_t onFrameSkip()
5267 {
5268 FrameSkip = !FrameSkip;
5269 return D_O_K;
5270 }
5271
5272 int32_t onSaveDragResize()
5273 {
5274 SaveDragResize = !SaveDragResize;
5275 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5276 return D_O_K;
5277 }
5278
5279 int32_t onDragAspect()
5280 {
5281 DragAspect = !DragAspect;
5282 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5283 return D_O_K;
5284 }
5285
5286 int32_t onTransLayers()
5287 {
5288 TransLayers = !TransLayers;
5289 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5290 return D_O_K;
5291 }
5292
5293 int32_t onNESquit()
5294 {
5295 NESquit = !NESquit;
5296 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5297 return D_O_K;
5298 }
5299
5300 int32_t onVolKeys()
5301 {
5302 volkeys = !volkeys;
5303 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5304 return D_O_K;
5305 }
5306
5307 int32_t onShowFPS()
5308 {
5309 ShowFPS = !ShowFPS;
5310 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5311 return D_O_K;
5312 }
5313
5314 1095890898 bool is_Fkey(int32_t k)
5315 {
5316
2/2
✓ Branch 0 taken 111446532 times.
✓ Branch 1 taken 984444366 times.
1095890898 switch(k)
5317 {
5318 case KEY_F1:
5319 case KEY_F2:
5320 case KEY_F3:
5321 case KEY_F4:
5322 case KEY_F5:
5323 case KEY_F6:
5324 case KEY_F7:
5325 case KEY_F8:
5326 case KEY_F9:
5327 case KEY_F10:
5328 case KEY_F11:
5329 case KEY_F12:
5330 111446532 return true;
5331 }
5332
5333 984444366 return false;
5334 1095890898 }
5335
5336 void kb_getkey(DIALOG *d);
5337
5338 //Used by all keyboard key settings dialogues.
5339 void kb_clearjoystick(DIALOG *d)
5340 {
5341 d->flags|=D_SELECTED;
5342
5343 jwin_button_proc(MSG_DRAW,d,0);
5344 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5345 // text_mode(vc(11));
5346 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5347 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5348
5349 update_hw_screen(true);
5350
5351 clear_keybuf();
5352 int32_t k = next_press_key();
5353 clear_keybuf();
5354
5355 //shnarf
5356 //47=f1
5357 //59=esc
5358 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5359 // *((int32_t*)d->dp3) = k;
5360 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5361
5362
5363 d->flags&=~D_SELECTED;
5364 }
5365
5366 //Clears key to 0.
5367 //Used by all keyboard key settings dialogues.
5368 void kb_clearkey(DIALOG *d);
5369
5370 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5371 {
5372 switch(msg)
5373 {
5374 case MSG_KEY:
5375 case MSG_CLICK:
5376
5377 kb_clearjoystick(d);
5378
5379 while(gui_mouse_b())
5380 {
5381 clear_keybuf();
5382 rest(1);
5383 }
5384
5385 return D_REDRAW;
5386 }
5387
5388 return jwin_button_proc(msg,d,c);
5389 }
5390
5391 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5392 //Only used in keyboard settings dialogues to clear keys.
5393 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5394
5395 int32_t j_getbtn(DIALOG *d)
5396 {
5397 d->flags|=D_SELECTED;
5398 jwin_button_proc(MSG_DRAW,d,0);
5399 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5400 // text_mode(vc(11));
5401 int32_t y = screen->h/2 - 12;
5402 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5403 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5404 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5405
5406 update_hw_screen(true);
5407
5408 int32_t b = next_joy_input(true);
5409 if (b == -2)
5410 return D_CLOSE;
5411
5412 if(b>=0)
5413 *((int32_t*)d->dp3) = b;
5414
5415 d->flags&=~D_SELECTED;
5416
5417 return D_O_K;
5418 }
5419
5420 void j_getstick(DIALOG *d)
5421 {
5422 d->flags|=D_SELECTED;
5423 jwin_button_proc(MSG_DRAW,d,0);
5424 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5425 // text_mode(vc(11));
5426 int32_t y = screen->h/2 - 12;
5427 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5428 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5429 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5430
5431 update_hw_screen(true);
5432
5433 int32_t b = next_joy_input(false);
5434
5435 if(b>=0)
5436 *((int32_t*)d->dp3) = b;
5437
5438 d->flags&=~D_SELECTED;
5439 }
5440
5441 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5442 {
5443 switch(msg)
5444 {
5445 case MSG_KEY:
5446 case MSG_CLICK:
5447
5448 int ret = j_getbtn(d);
5449 if (ret != D_O_K)
5450 return ret;
5451
5452 while(gui_mouse_b()) {
5453 rest(1);
5454 clear_keybuf();
5455 }
5456
5457 return D_REDRAW;
5458 }
5459
5460 return jwin_button_proc(msg,d,c);
5461 }
5462
5463 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5464 {
5465 switch(msg)
5466 {
5467 case MSG_KEY:
5468 case MSG_CLICK:
5469
5470 j_getstick(d);
5471
5472 while(gui_mouse_b()) {
5473 rest(1);
5474 clear_keybuf();
5475 }
5476
5477 return D_REDRAW;
5478 }
5479
5480 return jwin_button_proc(msg,d,c);
5481 }
5482
5483 //shnarf
5484 extern const char *key_str[];
5485 std::string get_keystr(int key);
5486
5487 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5488 //extern int32_t zcmusic_bufsz;
5489
5490 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5491 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5492 str_primary_stick[80], str_secondary_stick[80];
5493
5494 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5495 {
5496 //these are here to bypass compiler warnings about unused arguments
5497 c=c;
5498
5499 if (d->w == 1)
5500 {
5501 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5502 {
5503 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5504 return D_CLOSE;
5505 }
5506 }
5507
5508 if(msg==MSG_DRAW)
5509 {
5510 switch(d->w)
5511 {
5512 case 0:
5513 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5514 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5515 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5516 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5517 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5518 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5519 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5520 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5521 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5522 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5523 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5524 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5525 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5526 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5527 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5528 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5529 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5530 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5531 break;
5532
5533 case 1:
5534 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5535 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5536 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5537 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5538 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5539 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5540 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5541 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5542 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5543 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5544 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5545 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5546 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5547 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5548 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5549 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5550 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5551 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5552 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5553 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5554 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5555 break;
5556
5557 case 2:
5558 sprintf(str_a," %3d",midi_volume);
5559 sprintf(str_b," %3d",digi_volume);
5560 sprintf(str_l," %3d",emusic_volume);
5561 sprintf(str_m," %3dKB",zcmusic_bufsz);
5562 sprintf(str_r," %3d",sfx_volume);
5563 strcpy(str_s,pan_str[pan_style]);
5564 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5565 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5566 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5567 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5568 break;
5569 }
5570 }
5571
5572 return D_O_K;
5573 }
5574
5575 int32_t set_vol(void *dp3, int32_t d2)
5576 {
5577 switch(((int32_t*)dp3)[0])
5578 {
5579 case 0:
5580 midi_volume = zc_min(d2<<3,255);
5581 break;
5582
5583 case 1:
5584 digi_volume = zc_min(d2<<3,255);
5585 break;
5586
5587 case 2:
5588 emusic_volume = zc_min(d2<<3,255);
5589 break;
5590
5591 case 3:
5592 sfx_volume = zc_min(d2<<3,255);
5593 break;
5594 }
5595
5596 // text_mode(vc(11));
5597 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5598 return D_O_K;
5599 }
5600
5601 int32_t set_pan(void *dp3, int32_t d2)
5602 {
5603 pan_style = vbound(d2,0,3);
5604 // text_mode(vc(11));
5605 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5606 return D_O_K;
5607 }
5608
5609 int32_t set_buf(void *dp3, int32_t d2)
5610 {
5611 // text_mode(vc(11));
5612 zcmusic_bufsz = d2 + 1;
5613 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5614 return D_O_K;
5615 }
5616
5617 static int32_t gamepad_joys_list[] =
5618 {
5619 61,
5620 -1
5621 };
5622
5623 static int32_t gamepad_btn_list[] =
5624 {
5625 6,
5626 7,8,9,10,11,12,13,14,15,16,17,
5627 18,19,20,21,22,23,24,25,26,27,28,
5628 29,30,31,32,33,34,35,36,37,38,39,
5629 -1
5630 };
5631
5632 static int32_t gamepad_dirs_list[] =
5633 {
5634 40,41,42,43,
5635 44,45,46,47,
5636 48,49,50,51,
5637 52,53,54,55,
5638 56,57,58,59,
5639 60,
5640 -1
5641 };
5642
5643 static TABPANEL gamepad_tabs[] =
5644 {
5645 // (text)
5646 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5647 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5648 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5649 { NULL, 0, NULL, 0, NULL }
5650 };
5651
5652 const char *joy_list(int32_t index, int32_t *list_size)
5653 {
5654 if (index == -1)
5655 {
5656 *list_size = al_get_num_joysticks();
5657 return NULL;
5658 }
5659
5660 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5661 if (!joy)
5662 {
5663 return "?";
5664 }
5665
5666 return al_get_joystick_name(joy);
5667 }
5668
5669 117 static ListData joy__list(joy_list, &font);
5670
5671 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5672 {
5673 int32_t d2 = d->d2;
5674 int32_t ret = jwin_droplist_proc(msg,d,c);
5675
5676 if(d2!=d->d2)
5677 {
5678 joystick_index = d->d2;
5679 ret |= D_REDRAW_ALL;
5680 }
5681
5682 return ret;
5683 }
5684
5685 static DIALOG gamepad_dlg[] =
5686 {
5687 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5688 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5689 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5690 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5691 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5692 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5693 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5694 // 6
5695 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5696 // 7
5697 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5698 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5699 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5700 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5701 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5702 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5703 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5704 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5705 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5706 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5707 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5708 // 18
5709 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5710 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5711 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5712 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5713 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5714 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5715 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5716 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5717 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5718 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5719 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5720 // 29
5721 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5722 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5723 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5724 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5725 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5726 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5727 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5728 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5729 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5730 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5731 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5732 // 40
5733 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5734 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5735 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5736 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5737 // 44
5738 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5739 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5740 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5741 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5742 // 48
5743 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5744 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5745 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5746 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5747 // 52
5748 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5749 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5750 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5751 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5752 // 56
5753 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5754 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5755 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5756 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5757 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5758
5759 // 61
5760 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5761
5762 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5763 };
5764
5765 static int32_t keyboard_keys_list[] =
5766 {
5767 6,7,8,9,10,
5768 11,12,13,14,15,16,17,18,19,20,
5769 21,22,23,24,25,26,27,28,29,30,
5770 31,32,33,34,35,36,37,38,39,40,
5771 -1
5772 };
5773
5774 static int32_t keyboard_dirs_list[] =
5775 {
5776 41,42,43,44,
5777 45,46,47,48,
5778 49,50,51,52,
5779 53,54,55,56,
5780 -1
5781 };
5782
5783 static int32_t keyboard_mods_list[] =
5784 {
5785 57,58,59,60,
5786 61,62,63,64,
5787 65,66,67,68,
5788 69,70,71,72,
5789 -1
5790 };
5791
5792 static TABPANEL keyboard_control_tabs[] =
5793 {
5794 // (text)
5795 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5796 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5797 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5798 { NULL, 0, NULL, 0, NULL }
5799 };
5800
5801 static DIALOG keyboard_control_dlg[] =
5802 {
5803 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5804 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5805 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5806 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5807 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5808 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5809 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5810 // Keys
5811 // 6
5812 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5813 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5814 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5815 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5816 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5817 // 11
5818 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5819 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5820 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5821 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5822 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5823 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5824 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5825 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5826 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5827 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5828 // 21
5829 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5830 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5831 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5832 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5833 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5834 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5835 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5836 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5837 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5838 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5839 // 31
5840 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5841 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5842 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5843 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5844 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5845 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5846 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5847 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5848 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5849 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5850 // Dirs
5851 // 41
5852 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5853 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5854 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5855 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5856 // 45
5857 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5858 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5859 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5860 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5861 // 49
5862 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5863 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5864 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5865 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5866 // 53
5867 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5868 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5869 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5870 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5871 // Mods
5872 // 57
5873 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5874 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5875 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5876 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5877 // 61
5878 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5879 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5880 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5881 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5882 // 65
5883 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5884 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5885 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5886 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5887 // 69
5888 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5889 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5890 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5891 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5892 // 73
5893 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5894 };
5895
5896 /*
5897 int32_t midi_dp[3] = {0,147,104};
5898 int32_t digi_dp[3] = {1,147,120};
5899 int32_t pan_dp[3] = {0,147,136};
5900 int32_t buf_dp[3] = {0,147,152};
5901 */
5902 int32_t midi_dp[3] = {0,0,0};
5903 int32_t digi_dp[3] = {1,0,0};
5904 int32_t emus_dp[3] = {2,0,0};
5905 int32_t buf_dp[3] = {0,0,0};
5906 int32_t sfx_dp[3] = {3,0,0};
5907 int32_t pan_dp[3] = {0,0,0};
5908
5909 static DIALOG sound_dlg[] =
5910 {
5911 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5912 117 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5913 117 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5914 117 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5915 117 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5916 117 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5917 117 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5918 117 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5919 117 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5920 117 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5921 117 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5922 // 10
5923 117 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5924 117 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5925 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5926 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5927 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5928 117 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5929 117 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5930 117 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5931 117 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5932 117 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5933 //20
5934 117 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5935 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5936 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5937 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5938 117 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5939 117 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5940 117 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5941 117 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5942 117 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5943 117 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5944 //30
5945 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5946 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5948 117 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 };
5950
5951 char zc_builddate[80];
5952 char zc_aboutstr[80];
5953
5954 static DIALOG about_dlg[] =
5955 {
5956 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5957 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5958 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5959 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5960 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5961 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5962 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5963 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5964 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5965 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5966 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5967 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5968 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5969 };
5970
5971
5972 static DIALOG quest_dlg[] =
5973 {
5974 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5975 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5976 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5977 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5978 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5979 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5980 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5981 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5982 { jwin_text_proc, 130, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5983 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5984 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5985 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5986 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5987 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5988 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5989 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5990 };
5991
5992 static DIALOG triforce_dlg[] =
5993 {
5994 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5995 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5996 // 1
5997 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5998 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5999 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6000 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6001 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6002 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6003 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6004 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6005 // 9
6006 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6007 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6008 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6010 };
6011
6012 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6013 {
6014 go();
6015 int32_t ret=0;
6016 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6017 comeback();
6018 return ret != 0;
6019 }
6020
6021
6022 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6023 {
6024 if(def!=modulepath)
6025 strcpy(modulepath,def);
6026
6027 if(!usefilename)
6028 {
6029 int32_t i=(int32_t)strlen(modulepath);
6030
6031 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6032 modulepath[i--]=0;
6033 }
6034
6035 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6036 int32_t ret=0;
6037 int32_t sel=0;
6038
6039 if(list==NULL)
6040 {
6041 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6042 }
6043 else
6044 {
6045 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6046 }
6047
6048 return ret!=0;
6049 }
6050
6051 int32_t onToggleRecordingNewSaves()
6052 {
6053 if (zc_get_config("zeldadx", "replay_new_saves", false))
6054 {
6055 zc_set_config("zeldadx", "replay_new_saves", false);
6056 }
6057 else
6058 {
6059 zc_set_config("zeldadx", "replay_new_saves", true);
6060 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6061 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6062 }
6063 return D_O_K;
6064 }
6065
6066 int32_t onToggleSnapshotAllFrames()
6067 {
6068 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6069 return D_O_K;
6070 }
6071
6072 int32_t onStopReplayOrRecord()
6073 {
6074 if (replay_is_replaying())
6075 {
6076 replay_quit();
6077 }
6078 else if (replay_get_mode() == ReplayMode::Record)
6079 {
6080 if (!replay_get_meta_bool("test_mode"))
6081 {
6082 jwin_alert("Recording", "You cannot stop recording a save file.",
6083 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6084 return D_CLOSE;
6085 }
6086
6087 if (jwin_alert("Stop Recording",
6088 "Save replay to disk and stop recording?",
6089 "This will stop the recording.",
6090 NULL,
6091 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6092 return D_CLOSE;
6093
6094 replay_save();
6095 replay_stop();
6096 }
6097 return D_O_K;
6098 }
6099
6100 static int32_t handle_on_load_replay(ReplayMode mode)
6101 {
6102 if (Playing)
6103 {
6104 if (jwin_alert("Replay - Warning!",
6105 "Loading a replay will exit the current game.",
6106 "All unsaved progress will be lost.",
6107 "Do you wish to continue?",
6108 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6109 return D_CLOSE;
6110 }
6111
6112 std::string mode_string = replay_mode_to_string(mode);
6113 mode_string[0] = std::toupper(mode_string[0]);
6114
6115 std::string line_1 = "Select a replay file to play back.";
6116 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6117 std::string line_3 = "You can stop the replay and take over manually any time.";
6118 if (mode == ReplayMode::Update)
6119 {
6120 line_1 = "Select a replay file to update.";
6121 line_2 = "WARNING: be sure to back up the zplay file";
6122 line_3 = "and verify that the updated replay works as expected!";
6123 }
6124
6125 if (jwin_alert(mode_string.c_str(),
6126 line_1.c_str(),
6127 line_2.c_str(),
6128 line_3.c_str(),
6129 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6130 {
6131 char replay_path[2048];
6132 strcpy(replay_path, "replays/");
6133 if (jwin_file_select_ex(
6134 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6135 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6136 return D_CLOSE;
6137
6138 replay_quit();
6139 load_replay_file_deferred(mode, replay_path);
6140 Quit = qRESET;
6141 return D_CLOSE;
6142 }
6143 return D_O_K;
6144 }
6145
6146 int32_t onLoadReplay()
6147 {
6148 return handle_on_load_replay(ReplayMode::Replay);
6149 }
6150
6151 int32_t onLoadReplayAssert()
6152 {
6153 return handle_on_load_replay(ReplayMode::Assert);
6154 }
6155
6156 int32_t onLoadReplayUpdate()
6157 {
6158 return handle_on_load_replay(ReplayMode::Update);
6159 }
6160
6161 int32_t onSaveReplay()
6162 {
6163 if (replay_get_mode() == ReplayMode::Record)
6164 {
6165 if (!replay_get_meta_bool("test_mode"))
6166 {
6167 if (jwin_alert("Save Replay",
6168 "This will save a copy of the replay up to this point.",
6169 "The official replay file will be untouched.",
6170 "Do you wish to continue?",
6171 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6172 return D_CLOSE;
6173
6174 char replay_path[2048];
6175 strcpy(replay_path, replay_get_replay_path().string().c_str());
6176 if (jwin_file_select_ex(
6177 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6178 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6179 return D_CLOSE;
6180
6181 if (fileexists(replay_path))
6182 {
6183 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6184 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6185 return D_CLOSE;
6186 }
6187
6188 replay_save(replay_path);
6189 }
6190 else
6191 {
6192 replay_save();
6193 }
6194 }
6195 return D_O_K;
6196 }
6197
6198 static MENU replay_menu[] =
6199 {
6200 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6201 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6202 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6203 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6204 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6205 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6206 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6207
6208 { NULL, NULL, NULL, 0, NULL }
6209 };
6210
6211 static DIALOG credits_dlg[] =
6212 {
6213 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6214 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6215 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6216 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6217 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6218 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6219 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6220 };
6221
6222 117 static ListData dmap_list(dmaplist, &font);
6223
6224 static DIALOG goto_dlg[] =
6225 {
6226 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6227 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6228 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6229 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6230 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6231 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6232 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6233 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6234 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6235 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6236 };
6237
6238 int32_t onGoTo()
6239 {
6240 bool music = false;
6241 music = music;
6242 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6243
6244 goto_dlg[0].dp2=get_zc_font(font_lfont);
6245 goto_dlg[4].d2=cheat_goto_dmap;
6246 goto_dlg[6].dp=cheat_goto_screen_str;
6247
6248 clear_keybuf();
6249
6250 large_dialog(goto_dlg);
6251
6252 if(do_zqdialog(goto_dlg,4)==1)
6253 {
6254 // dmap, screen
6255 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6256 };
6257
6258 return D_O_K;
6259 }
6260
6261 int32_t onGoToComplete()
6262 {
6263 if(!Playing)
6264 {
6265 return D_O_K;
6266 }
6267
6268 enter_sys_pal();
6269 music_pause();
6270 pause_all_sfx();
6271 onGoTo();
6272 eat_buttons();
6273
6274 zc_readrawkey(KEY_ESC);
6275
6276 exit_sys_pal();
6277 music_resume();
6278 resume_all_sfx();
6279 return D_O_K;
6280 }
6281
6282 int32_t onCredits()
6283 {
6284 return D_O_K;
6285 }
6286
6287 const char *midilist(int32_t index, int32_t *list_size)
6288 {
6289 if(index<0)
6290 {
6291 *list_size=0;
6292
6293 for(int32_t i=0; i<MAXMIDIS; i++)
6294 if(tunes[i].data)
6295 ++(*list_size);
6296
6297 return NULL;
6298 }
6299
6300 int32_t i=0,m=0;
6301
6302 while(m<=index && i<=MAXMIDIS)
6303 {
6304 if(tunes[i].data)
6305 ++m;
6306
6307 ++i;
6308 }
6309
6310 --i;
6311
6312 if(i==MAXMIDIS && m<index)
6313 return "(null)";
6314
6315 return tunes[i].title;
6316 }
6317
6318 /* ------- MIDI info stuff -------- */
6319
6320 char *text;
6321 midi_info *zmi;
6322 bool dialog_running;
6323 bool listening;
6324
6325 void get_info(int32_t index);
6326
6327 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6328 {
6329 int32_t d2 = d->d2;
6330 int32_t ret = jwin_droplist_proc(msg,d,c);
6331
6332 if(d2!=d->d2)
6333 {
6334 get_info(d->d2);
6335 }
6336
6337 return ret;
6338 }
6339
6340 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6341 {
6342 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6343
6344 int32_t ret = jwin_button_proc(msg,d,c);
6345
6346 if(ret == D_CLOSE)
6347 {
6348 // get current midi index
6349 int32_t index = (d+(d->d1))->d2;
6350 int32_t i=0, m=0;
6351
6352 while(m<=index && i<=MAXMIDIS)
6353 {
6354 if(tunes[i].data)
6355 ++m;
6356
6357 ++i;
6358 }
6359
6360 --i;
6361 jukebox(i);
6362 listening = true;
6363 ret = D_O_K;
6364 }
6365
6366 return ret;
6367 }
6368
6369 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6370 {
6371 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6372
6373 int32_t ret = jwin_button_proc(msg,d,c);
6374
6375 if(ret == D_CLOSE)
6376 {
6377 // get current midi index
6378 int32_t index = (d+(d->d1))->d2;
6379 int32_t i=0, m=0;
6380
6381 while(m<=index && i<=MAXMIDIS)
6382 {
6383 if(tunes[i].data)
6384 ++m;
6385
6386 ++i;
6387 }
6388
6389 --i;
6390
6391 // get file name
6392
6393 int32_t sel=0;
6394 //struct ffblk f;
6395 char title[40] = "Save MIDI: ";
6396 char fname[2048];
6397 memset(fname,0,2048);
6398 static EXT_LIST list[] =
6399 {
6400 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6401 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6402 { NULL, NULL }
6403 };
6404
6405 strcpy(title+11, tunes[i].title);
6406 title[39] = '\0';
6407
6408 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6409 goto done;
6410
6411 if(exists(fname))
6412 {
6413 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6414 goto done;
6415 }
6416
6417 // save midi i
6418
6419 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6420 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6421
6422 done:
6423 chop_path(fname);
6424 ret = D_REDRAW;
6425 }
6426
6427 return ret;
6428 }
6429
6430 117 static ListData midi_list(midilist, &font);
6431
6432 static DIALOG midi_dlg[] =
6433 {
6434 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6435 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6436 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6437 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6438 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6439 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6440 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6441 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6442 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6443 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6444 };
6445
6446 void get_info(int32_t index)
6447 {
6448 int32_t i=0, m=0;
6449
6450 while(m<=index && i<=MAXMIDIS)
6451 {
6452 if(tunes[i].data)
6453 ++m;
6454
6455 ++i;
6456 }
6457
6458 --i;
6459
6460 if(i==MAXMIDIS && m<index)
6461 strcpy(text,"(null)");
6462 else
6463 {
6464 get_midi_info((MIDI*)tunes[i].data,zmi);
6465 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6466 }
6467
6468 midi_dlg[0].dp2=get_zc_font(font_lfont);
6469 midi_dlg[3].dp = text;
6470 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6471 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6472
6473 if(dialog_running)
6474 {
6475 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6476 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6477 }
6478 }
6479
6480 int32_t onMIDICredits()
6481 {
6482 text = (char*)malloc(4096);
6483 zmi = (midi_info*)malloc(sizeof(midi_info));
6484
6485 if(!text || !zmi)
6486 {
6487 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6488 return D_O_K;
6489 }
6490
6491 bool do_pause_midi = midi_pos >= 0 && currmidi;
6492 auto restore_midi = currmidi;
6493 if(do_pause_midi)
6494 {
6495 paused_midi_pos = midi_pos;
6496 stop_midi();
6497 midi_suspended = midissuspHALTED;
6498 }
6499
6500 midi_dlg[0].dp2=get_zc_font(font_lfont);
6501 midi_dlg[2].d1 = 0;
6502 midi_dlg[2].d2 = 0;
6503 midi_dlg[4].flags = D_EXIT;
6504 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6505
6506 listening = false;
6507 dialog_running=false;
6508 get_info(0);
6509
6510 dialog_running=true;
6511
6512 large_dialog(midi_dlg);
6513
6514 do_zqdialog(midi_dlg,0);
6515 dialog_running=false;
6516
6517 if(listening)
6518 music_stop();
6519
6520 if(do_pause_midi)
6521 {
6522 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6523 midi_suspended = midissuspRESUME;
6524 currmidi = restore_midi;
6525 midi_pos = paused_midi_pos;
6526 }
6527
6528 if(text) free(text);
6529 if(zmi) free(zmi);
6530 return D_O_K;
6531 }
6532
6533 int32_t onAbout()
6534 {
6535 char buf1[80]={0};
6536 std::ostringstream oss;
6537 sprintf(buf1,ZC_PLAYER_NAME);
6538 oss << buf1 << '\n';
6539 sprintf(buf1,"Version: %s", getVersionString());
6540 oss << buf1 << '\n';
6541 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6542 oss << buf1 << '\n';
6543 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6544 oss << buf1 << '\n';
6545
6546 InfoDialog("About ZC", oss.str()).show();
6547 return D_O_K;
6548 }
6549
6550 int32_t onQuest()
6551 {
6552 char fname[100];
6553 strcpy(fname, get_filename(qstpath));
6554 quest_dlg[0].dp2=get_zc_font(font_lfont);
6555 quest_dlg[1].dp = fname;
6556
6557 if(QHeader.quest_number==0)
6558 sprintf(str_a,"Custom");
6559 else
6560 sprintf(str_a,"%d",QHeader.quest_number);
6561
6562 sprintf(str_s,"%s",QHeader.getVerStr());
6563
6564 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6565 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6566
6567 large_dialog(quest_dlg);
6568
6569 do_zqdialog(quest_dlg, 0);
6570 return D_O_K;
6571 }
6572
6573 void call_vidmode_dlg();
6574 int32_t onVidMode()
6575 {
6576 call_vidmode_dlg();
6577 return D_O_K;
6578 }
6579
6580 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6581 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6582 //Added an extra statement, so that if the key is cleared to 0, the cleared
6583 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6584
6585 void load_ukeys(int32_t* arr)
6586 {
6587 arr[ukey_a] = Akey;
6588 arr[ukey_b] = Bkey;
6589 arr[ukey_s] = Skey;
6590 arr[ukey_l] = Lkey;
6591 arr[ukey_r] = Rkey;
6592 arr[ukey_p] = Pkey;
6593 arr[ukey_ex1] = Exkey1;
6594 arr[ukey_ex2] = Exkey2;
6595 arr[ukey_ex3] = Exkey3;
6596 arr[ukey_ex4] = Exkey4;
6597 arr[ukey_du] = DUkey;
6598 arr[ukey_dd] = DDkey;
6599 arr[ukey_dl] = DLkey;
6600 arr[ukey_dr] = DRkey;
6601 arr[ukey_mod1a] = cheat_modifier_keys[0];
6602 arr[ukey_mod1b] = cheat_modifier_keys[1];
6603 arr[ukey_mod2a] = cheat_modifier_keys[2];
6604 arr[ukey_mod2b] = cheat_modifier_keys[3];
6605 };
6606
6607 static const char* ukey_names[] = {
6608 "A", "B", "Start", "L", "R", "Map",
6609 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6610 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6611 "Cheat Mod R1", "Cheat Mod R2",
6612 };
6613 std::string get_ukey_name(int32_t k)
6614 {
6615 if (k < num_ukey) return ukey_names[k];
6616 return "";
6617 }
6618
6619 int32_t onKeyboard()
6620 {
6621 int32_t a = Akey;
6622 int32_t b = Bkey;
6623 int32_t s = Skey;
6624 int32_t l = Lkey;
6625 int32_t r = Rkey;
6626 int32_t p = Pkey;
6627 int32_t ex1 = Exkey1;
6628 int32_t ex2 = Exkey2;
6629 int32_t ex3 = Exkey3;
6630 int32_t ex4 = Exkey4;
6631 int32_t du = DUkey;
6632 int32_t dd = DDkey;
6633 int32_t dl = DLkey;
6634 int32_t dr = DRkey;
6635 int32_t mod1a = cheat_modifier_keys[0];
6636 int32_t mod1b = cheat_modifier_keys[1];
6637 int32_t mod2a = cheat_modifier_keys[2];
6638 int32_t mod2b = cheat_modifier_keys[3];
6639 bool done=false;
6640 int32_t ret;
6641
6642 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6643
6644 large_dialog(keyboard_control_dlg);
6645
6646 while(!done)
6647 {
6648 ret = do_zqdialog(keyboard_control_dlg,3);
6649
6650 if(ret==3) // OK
6651 {
6652 int32_t ukeys[num_ukey];
6653 load_ukeys(ukeys);
6654 std::vector<std::string> uniqueError;
6655 for(int32_t q = 0; q < num_ukey; ++q)
6656 {
6657 for(int32_t p = q+1; p < num_ukey; ++p)
6658 {
6659 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6660 {
6661 char buf[64];
6662 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6663 std::string str(buf);
6664 uniqueError.push_back(str);
6665 }
6666 }
6667 }
6668 if(uniqueError.size() == 0)
6669 {
6670 done = true;
6671 save_control_configs(true);
6672 }
6673 else
6674 {
6675 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6676 box_out("Cannot have duplicate keybinds!"); box_eol();
6677 for(std::vector<std::string>::iterator it = uniqueError.begin();
6678 it != uniqueError.end(); ++it)
6679 {
6680 box_out((*it).c_str()); box_eol();
6681 }
6682 box_end(true);
6683 }
6684 }
6685 else // Cancel
6686 {
6687 Akey = a;
6688 Bkey = b;
6689 Skey = s;
6690 Lkey = l;
6691 Rkey = r;
6692 Pkey = p;
6693 Exkey1 = ex1;
6694 Exkey2 = ex2;
6695 Exkey3 = ex3;
6696 Exkey4 = ex4;
6697 DUkey = du;
6698 DDkey = dd;
6699 DLkey = dl;
6700 DRkey = dr;
6701 cheat_modifier_keys[0] = mod1a;
6702 cheat_modifier_keys[1] = mod1b;
6703 cheat_modifier_keys[2] = mod2a;
6704 cheat_modifier_keys[3] = mod2b;
6705
6706 done=true;
6707 }
6708
6709 rest(1);
6710 }
6711
6712 return D_O_K;
6713 }
6714
6715 int32_t onGamepad()
6716 {
6717 if (al_get_num_joysticks() == 0)
6718 {
6719 InfoDialog("ZC", "No gamepads detected.").show();
6720 return D_O_K;
6721 }
6722
6723 int32_t a = Abtn;
6724 int32_t b = Bbtn;
6725 int32_t s = Sbtn;
6726 int32_t l = Lbtn;
6727 int32_t r = Rbtn;
6728 int32_t m = Mbtn;
6729 int32_t p = Pbtn;
6730 int32_t ex1 = Exbtn1;
6731 int32_t ex2 = Exbtn2;
6732 int32_t ex3 = Exbtn3;
6733 int32_t ex4 = Exbtn4;
6734 int32_t up = DUbtn;
6735 int32_t down = DDbtn;
6736 int32_t left = DLbtn;
6737 int32_t right = DRbtn;
6738 int32_t joy = joystick_index;
6739 int32_t stick_1 = js_stick_1_x_stick;
6740 int32_t stick_2 = js_stick_2_x_stick;
6741
6742 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6743 if(analog_movement)
6744 gamepad_dlg[56].flags|=D_SELECTED;
6745 else
6746 gamepad_dlg[56].flags&=~D_SELECTED;
6747
6748 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6749 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6750 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6751 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6752 // requires remapping every time.
6753 if (joystick_index >= al_get_num_joysticks())
6754 joystick_index = 0;
6755 gamepad_dlg[61].d2 = joystick_index;
6756
6757 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6758 if (!gamepad_dlg_cur_joystick)
6759 {
6760 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6761 return D_CLOSE;
6762 }
6763
6764 large_dialog(gamepad_dlg);
6765
6766 int32_t ret = do_zqdialog(gamepad_dlg,4);
6767
6768 if(ret == 4) //OK
6769 {
6770 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6771 joystick_index = gamepad_dlg[61].d2;
6772 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6773 if (!gamepad_dlg_cur_joystick)
6774 {
6775 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6776 return D_CLOSE;
6777 }
6778 js_stick_1_y_stick = js_stick_1_x_stick;
6779 js_stick_2_y_stick = js_stick_2_x_stick;
6780 save_control_configs(false);
6781 }
6782 else //Cancel
6783 {
6784 Abtn = a;
6785 Bbtn = b;
6786 Sbtn = s;
6787 Lbtn = l;
6788 Rbtn = r;
6789 Mbtn = m;
6790 Pbtn = p;
6791 Exbtn1 = ex1;
6792 Exbtn2 = ex2;
6793 Exbtn3 = ex3;
6794 Exbtn4 = ex4;
6795 DUbtn = up;
6796 DDbtn = down;
6797 DLbtn = left;
6798 DRbtn = right;
6799 joystick_index = joy;
6800 js_stick_1_x_stick = stick_1;
6801 js_stick_2_x_stick = stick_2;
6802 }
6803
6804 return D_O_K;
6805 }
6806
6807 int32_t onCheatKeys()
6808 {
6809 int32_t oldcheats[Cheat::Last][2];
6810 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6811
6812 bool done=false;
6813
6814 while(!done)
6815 {
6816 bool confirm = false;
6817 CheatKeysDialog(&confirm).show();
6818 if(confirm) // OK
6819 {
6820 std::vector<std::string> uniqueError;
6821 char buf[512];
6822 for(size_t q = 1; q < Cheat::Last; ++q)
6823 {
6824 if(cheatkeys[q][1] && !cheatkeys[q][0])
6825 {
6826 cheatkeys[q][0] = cheatkeys[q][1];
6827 cheatkeys[q][1] = 0;
6828 }
6829 }
6830 for(size_t q = 1; q < Cheat::Last; ++q)
6831 {
6832 if(!bindable_cheat((Cheat)q)) continue;
6833 for(size_t p = q+1; p < Cheat::Last; ++p)
6834 {
6835 if(!bindable_cheat((Cheat)p)) continue;
6836 for(size_t q2 = 0; q2 <= 1; ++q2)
6837 for(size_t p2 = 0; p2 <= 1; ++p2)
6838 {
6839 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6840 {
6841 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6842 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6843 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6844 get_keystr(cheatkeys[q][q2])));
6845 }
6846 }
6847 }
6848 }
6849 if(uniqueError.size() == 0)
6850 {
6851 done = true;
6852 save_cheatkeys();
6853 }
6854 else
6855 {
6856 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6857 box_out("Cannot have duplicate keybinds!"); box_eol();
6858 for(std::vector<std::string>::iterator it = uniqueError.begin();
6859 it != uniqueError.end(); ++it)
6860 {
6861 box_out((*it).c_str()); box_eol();
6862 }
6863 box_end(true);
6864 }
6865 }
6866 else // Cancel
6867 {
6868 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6869 done=true;
6870 }
6871 rest(1);
6872 }
6873
6874 return D_O_K;
6875 }
6876
6877 int32_t onSound()
6878 {
6879 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6880 {
6881 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6882 {
6883 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6884 }
6885 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6886 {
6887 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6888 }
6889 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6890 {
6891 emusic_volume = (int32_t)FFCore.usr_music_volume;
6892 }
6893 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6894 {
6895 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6896 }
6897 }
6898 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6899 {
6900 pan_style = (int32_t)FFCore.usr_panstyle;
6901 }
6902
6903 int32_t m = midi_volume;
6904 int32_t d = digi_volume;
6905 int32_t e = emusic_volume;
6906 int32_t b = zcmusic_bufsz;
6907 int32_t s = sfx_volume;
6908 int32_t p = pan_style;
6909 pan_style = vbound(pan_style,0,3);
6910
6911 sound_dlg[0].dp2=get_zc_font(font_lfont);
6912
6913 large_dialog(sound_dlg);
6914
6915 midi_dp[1] = sound_dlg[6].x;
6916 midi_dp[2] = sound_dlg[6].y;
6917 digi_dp[1] = sound_dlg[7].x;
6918 digi_dp[2] = sound_dlg[7].y;
6919 emus_dp[1] = sound_dlg[8].x;
6920 emus_dp[2] = sound_dlg[8].y;
6921 buf_dp[1] = sound_dlg[9].x;
6922 buf_dp[2] = sound_dlg[9].y;
6923 sfx_dp[1] = sound_dlg[10].x;
6924 sfx_dp[2] = sound_dlg[10].y;
6925 pan_dp[1] = sound_dlg[11].x;
6926 pan_dp[2] = sound_dlg[11].y;
6927 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6928 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6929 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6930 sound_dlg[18].d2 = zcmusic_bufsz;
6931 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6932 sound_dlg[20].d2 = pan_style;
6933
6934 int32_t ret = do_zqdialog(sound_dlg,1);
6935
6936 if(ret==2)
6937 {
6938 master_volume(digi_volume,midi_volume);
6939 if (zcmusic)
6940 zcmusic_set_volume(zcmusic, emusic_volume);
6941
6942 int32_t temp_volume = sfx_volume;
6943 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6944 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6945 for(int32_t i=0; i<WAV_COUNT; ++i)
6946 {
6947 //allegro assertion fails when passing in -1 as voice -DD
6948 if(sfx_voice[i] > 0)
6949 voice_set_volume(sfx_voice[i], temp_volume);
6950 }
6951 zc_set_config(sfx_sect,"digi",digi_volume);
6952 zc_set_config(sfx_sect,"midi",midi_volume);
6953 zc_set_config(sfx_sect,"sfx",sfx_volume);
6954 zc_set_config(sfx_sect,"emusic",emusic_volume);
6955 zc_set_config(sfx_sect,"pan",pan_style);
6956 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6957 }
6958 else
6959 {
6960 midi_volume = m;
6961 digi_volume = d;
6962 emusic_volume = e;
6963 zcmusic_bufsz = b;
6964 sfx_volume = s;
6965 pan_style = p;
6966 }
6967
6968 return D_O_K;
6969 }
6970
6971 int32_t queding(char const* s1, char const* s2, char const* s3)
6972 {
6973 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6974 }
6975
6976 int32_t onQuit()
6977 {
6978 if(Playing)
6979 {
6980 int32_t ret=0;
6981
6982 if(get_qr(qr_NOCONTINUE))
6983 {
6984 if(standalone_mode)
6985 {
6986 ret=queding("End current game?",
6987 "The continue screen is disabled; the game",
6988 "will be reloaded from the last save.");
6989 }
6990 else
6991 {
6992 ret=queding("End current game?",
6993 "The continue screen is disabled. You will",
6994 "be returned to the file select screen.");
6995 }
6996 }
6997 else
6998 ret=queding("End current game?",NULL,NULL);
6999
7000 if(ret==1)
7001 {
7002 disableClickToFreeze=false;
7003 Quit=qQUIT;
7004
7005 // Trying to evade a door repair charge?
7006 if(repaircharge)
7007 {
7008 game->change_drupy(-repaircharge);
7009 repaircharge=0;
7010 }
7011
7012 return D_CLOSE;
7013 }
7014 }
7015
7016 return D_O_K;
7017 }
7018
7019 int32_t onTryQuitMenu()
7020 {
7021 return onTryQuit(true);
7022 }
7023
7024 int32_t onTryQuit(bool inMenu)
7025 {
7026 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7027 {
7028 if(active_cutscene.can_f6())
7029 {
7030 if(get_qr(qr_OLD_F6))
7031 {
7032 if(inMenu) onQuit();
7033 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7034 }
7035 else
7036 {
7037 disableClickToFreeze=false;
7038 GameFlags |= GAMEFLAG_TRYQUIT;
7039 }
7040 return D_CLOSE;
7041 }
7042 else active_cutscene.error();
7043 }
7044
7045 return D_O_K;
7046 }
7047
7048 int32_t onReset()
7049 {
7050 if(queding(" Reset system? ",NULL,NULL)==1)
7051 {
7052 disableClickToFreeze=false;
7053 Quit=qRESET;
7054 replay_quit();
7055 return D_CLOSE;
7056 }
7057
7058 return D_O_K;
7059 }
7060
7061 int32_t onExit()
7062 {
7063 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7064 {
7065 Quit=qEXIT;
7066 return D_CLOSE;
7067 }
7068
7069 return D_O_K;
7070 }
7071
7072 int32_t onDebug()
7073 {
7074 if(debug_enabled)
7075 set_debug(!get_debug());
7076 return D_O_K;
7077 }
7078
7079 int32_t onHeartBeep()
7080 {
7081 heart_beep=!heart_beep;
7082 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7083 return D_O_K;
7084 }
7085
7086 int32_t onSaveIndicator()
7087 {
7088 use_save_indicator = use_save_indicator ? 0 : 1;
7089 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7090 return D_O_K;
7091 }
7092
7093 int32_t onEpilepsy()
7094 {
7095 if(jwin_alert3(
7096 "Epilepsy Flash Reduction",
7097 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7098 "Disabling this will restore standard flash and wavy behaviour.",
7099 "Proceed?",
7100 "&Yes",
7101 "&No",
7102 NULL,
7103 'y',
7104 'n',
7105 0,
7106 get_zc_font(font_lfont)) == 1)
7107 {
7108 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7109 zc_set_config("zeldadx","checked_epilepsy",1);
7110 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7111 }
7112 return D_O_K;
7113 }
7114
7115 bool rc = false;
7116
7117 static DIALOG getnum_dlg[] =
7118 {
7119 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7120 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7121 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7122 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7123 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7124 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7125 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7126 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7127 };
7128
7129 int32_t getnumber(const char *prompt,int32_t initialval)
7130 {
7131 char buf[20];
7132 sprintf(buf,"%d",initialval);
7133 getnum_dlg[0].dp=(void *)prompt;
7134 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7135 getnum_dlg[2].dp=buf;
7136
7137 large_dialog(getnum_dlg);
7138
7139 if(do_zqdialog(getnum_dlg,2)==3)
7140 return atoi(buf);
7141
7142 return initialval;
7143 }
7144
7145 int32_t onLife()
7146 {
7147 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7148 cheats_enqueue(Cheat::Life, value);
7149 return D_O_K;
7150 }
7151
7152 int32_t onHeartC()
7153 {
7154 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7155 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7156 cheats_enqueue(Cheat::MaxLife, max_life);
7157 cheats_enqueue(Cheat::Life, life);
7158 return D_O_K;
7159 }
7160
7161 int32_t onMagicC()
7162 {
7163 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7164 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7165 cheats_enqueue(Cheat::MaxMagic, max_magic);
7166 cheats_enqueue(Cheat::Magic, magic);
7167 return D_O_K;
7168 }
7169
7170 int32_t onRupies()
7171 {
7172 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7173 cheats_enqueue(Cheat::Rupies, value);
7174 return D_O_K;
7175 }
7176
7177 int32_t onMaxBombs()
7178 {
7179 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7180 cheats_enqueue(Cheat::MaxBombs, value);
7181 cheats_enqueue(Cheat::Bombs, value);
7182 return D_O_K;
7183 }
7184
7185 int32_t onRefillLife()
7186 {
7187 cheats_enqueue(Cheat::Life, game->get_maxlife());
7188 return D_O_K;
7189 }
7190 int32_t onRefillMagic()
7191 {
7192 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7193 return D_O_K;
7194 }
7195 int32_t onClock()
7196 {
7197 cheats_enqueue(Cheat::Clock);
7198 return D_O_K;
7199 }
7200
7201 int32_t onQstPath()
7202 {
7203 char path[2048];
7204
7205 chop_path(qstdir);
7206 strcpy(path,qstdir);
7207
7208 go();
7209
7210 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7211 {
7212 chop_path(path);
7213 fix_filename_case(path);
7214 fix_filename_slashes(path);
7215 strcpy(qstdir,path);
7216 strcpy(qstpath,qstdir);
7217 zc_set_config("zeldadx","quest_dir",qstdir);
7218 flush_config_file();
7219 }
7220
7221 comeback();
7222 return D_O_K;
7223 }
7224
7225 #include "dialog/cheat_dialog.h"
7226 int32_t onCheat()
7227 {
7228 call_setcheat_dialog();
7229 game->set_cheat(maxcheat);
7230 if(cheat) game->did_cheat(true);
7231 return D_O_K;
7232 }
7233
7234 int32_t onCheatRupies()
7235 {
7236 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7237 return D_O_K;
7238 }
7239
7240 int32_t onCheatArrows()
7241 {
7242 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7243 return D_O_K;
7244 }
7245
7246 int32_t onCheatBombs()
7247 {
7248 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7249 return D_O_K;
7250 }
7251
7252 // *** screen saver
7253
7254 9287211 int32_t after_time()
7255 {
7256
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(ss_enable == 0)
7257 return INT_MAX;
7258
7259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 0)
7260 return 5 * 60;
7261
7262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 3)
7263 return ss_after * 15 * 60;
7264
7265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 13)
7266 return (ss_after - 3) * 60 * 60;
7267
7268 9287211 return MAX_IDLE + 1;
7269 9287211 }
7270
7271 static const char *after_str[15] =
7272 {
7273 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7274 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7275 "Never"
7276 };
7277
7278 const char *after_list(int32_t index, int32_t *list_size)
7279 {
7280 if(index < 0)
7281 {
7282 *list_size = 15;
7283 return NULL;
7284 }
7285
7286 return after_str[index];
7287 }
7288
7289 117 static ListData after__list(after_list, &font);
7290
7291 static DIALOG scrsaver_dlg[] =
7292 {
7293 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7294 117 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7295 117 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7296 117 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7297 117 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7298 117 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7299 117 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7300 117 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7301 117 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7302 117 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7303 117 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7304 117 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7305 117 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7306 117 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7307 };
7308
7309 int32_t onScreenSaver()
7310 {
7311 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7312 int32_t oldcfgs[3];
7313 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7314 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7315 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7316
7317 large_dialog(scrsaver_dlg);
7318
7319 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7320
7321 if(ret == 8 || ret == 9)
7322 {
7323 ss_after = scrsaver_dlg[5].d1;
7324 ss_speed = scrsaver_dlg[6].d2;
7325 ss_density = scrsaver_dlg[7].d2;
7326 if(oldcfgs[0] != ss_after)
7327 zc_set_config(cfg_sect,"ss_after",ss_after);
7328 if(oldcfgs[1] != ss_speed)
7329 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7330 if(oldcfgs[2] != ss_density)
7331 zc_set_config(cfg_sect,"ss_density",ss_density);
7332 }
7333
7334 if(ret == 9)
7335 // preview Screen Saver
7336 {
7337 clear_keybuf();
7338 Matrix(ss_speed, ss_density, 30);
7339 system_pal(true);
7340 sys_mouse();
7341 }
7342
7343 return D_O_K;
7344 }
7345
7346 /***** Menus *****/
7347
7348 static MENU game_menu[] =
7349 {
7350 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7351 { (char *)"", NULL, NULL, 0, NULL },
7352 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7353 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7354 { (char *)"", NULL, NULL, 0, NULL },
7355 #ifdef __EMSCRIPTEN__
7356 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7357 #elif defined(ALLEGRO_MACOSX)
7358 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7359 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7360 #else
7361 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7362 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7363 #endif
7364 { NULL, NULL, NULL, 0, NULL }
7365 };
7366
7367 static MENU snapshot_format_menu[] =
7368 {
7369 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7370 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7371 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7372 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7373 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7374 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7375 { NULL, NULL, NULL, 0, NULL }
7376 };
7377
7378 static MENU controls_menu[] =
7379 {
7380 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7381 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7382 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7383 { NULL, NULL, NULL, 0, NULL }
7384 };
7385
7386 static MENU name_entry_mode_menu[] =
7387 {
7388 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7389 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7390 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7391 { NULL, NULL, NULL, 0, NULL }
7392 };
7393
7394 static void set_controls_menu_active()
7395 {
7396
7397 }
7398
7399 static MENU window_menu[] =
7400 {
7401 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7402 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7403 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7404 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7405 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7406 { NULL, NULL, NULL, 0, NULL }
7407 };
7408 static MENU options_menu[] =
7409 {
7410 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7411 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7412 { "&Window Settings", NULL, window_menu, 0, NULL },
7413 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7414 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7415 { NULL, NULL, NULL, 0, NULL }
7416 };
7417 static MENU settings_menu[] =
7418 {
7419 { "&Sound...", onSound, NULL, 0, NULL },
7420 { "C&ontrols", NULL, controls_menu, 0, NULL },
7421 { "", NULL, NULL, 0, NULL },
7422 { "Options", NULL, options_menu, 0, NULL },
7423 { "", NULL, NULL, 0, NULL },
7424 //
7425 { "&Cap FPS\tF1", onThrottleFPS, NULL, 0, NULL },
7426 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7427 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7428 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7429 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7430 //
7431 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7432 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7433 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7434 { "", NULL, NULL, 0, NULL },
7435 { "Debu&g", onDebug, NULL, 0, NULL },
7436 //
7437 { NULL, NULL, NULL, 0, NULL }
7438 };
7439
7440
7441 static MENU misc_menu[] =
7442 {
7443 { (char *)"&About...", onAbout, NULL, 0, NULL },
7444 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7445 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7446 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7447 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7448 { (char *)"", NULL, NULL, 0, NULL },
7449 //5
7450 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7451 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7452 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7453 { (char *)"", NULL, NULL, 0, NULL },
7454 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7455 //10
7456 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7457 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7458 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7459 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7460 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7461 //15
7462 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7463 { NULL, NULL, NULL, 0, NULL }
7464 };
7465
7466 static MENU refill_menu[] =
7467 {
7468 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7469 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7470 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7471 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7472 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7473 { NULL, NULL, NULL, 0, NULL }
7474 };
7475
7476 static MENU show_menu[] =
7477 {
7478 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7479 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7480 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7481 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7482 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7483 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7484 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7485 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7486 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7487 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7488 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7489 { (char *)"", NULL, NULL, 0, NULL },
7490 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7491 { (char *)"", NULL, NULL, 0, NULL },
7492 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7493 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7494 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7495 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7496 { NULL, NULL, NULL, 0, NULL }
7497 };
7498
7499 static MENU cheat_menu[] =
7500 {
7501 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7502 { (char *)"", NULL, NULL, 0, NULL },
7503 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7504 { (char *)"", NULL, NULL, 0, NULL },
7505 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7506 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7507 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7508 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7509 { (char *)"", NULL, NULL, 0, NULL },
7510 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7511 { (char *)"", NULL, NULL, 0, NULL },
7512 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7513 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7514 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7515 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7516 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7517 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7518 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7519 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7520 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7521 { NULL, NULL, NULL, 0, NULL }
7522 };
7523
7524 #if DEVLEVEL > 0
7525 int32_t devLogging();
7526 int32_t devDebug();
7527 int32_t devTimestmp();
7528 #if DEVLEVEL > 1
7529 int32_t setCheat();
7530 #endif //DEVLEVEL > 1
7531 enum
7532 {
7533 dv_log,
7534 // dv_dbg,
7535 dv_tmpstmp,
7536 #if DEVLEVEL > 1
7537 dv_nil,
7538 dv_setcheat,
7539 #endif //DEVLEVEL > 1
7540 dv_max
7541 };
7542 static MENU dev_menu[] =
7543 {
7544 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7545 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7546 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7547 #if DEVLEVEL > 1
7548 { (char *)"", NULL, NULL, 0, NULL },
7549 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7550 #endif //DEVLEVEL > 1
7551 { NULL, NULL, NULL, 0, NULL }
7552 };
7553 int32_t devLogging()
7554 {
7555 dev_logging = !dev_logging;
7556 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7557 return D_O_K;
7558 }
7559 // int32_t devDebug()
7560 // {
7561 // dev_debug = !dev_debug;
7562 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7563 // return D_O_K;
7564 // }
7565 int32_t devTimestmp()
7566 {
7567 dev_timestmp = !dev_timestmp;
7568 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7569 return D_O_K;
7570 }
7571 #if DEVLEVEL > 1
7572 int32_t setCheat()
7573 {
7574 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7575 return D_O_K;
7576 }
7577 #endif //DEVLEVEL > 1
7578 #endif //DEVLEVEL > 0
7579
7580 MENU the_player_menu[] =
7581 {
7582 { (char *)"&Game", NULL, game_menu, 0, NULL },
7583 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7584 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7585 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7586 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7587 #if DEVLEVEL > 0
7588 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7589 #endif
7590 { NULL, NULL, NULL, 0, NULL }
7591 };
7592 int32_t onPauseInBackground()
7593 {
7594 if(jwin_alert3(
7595 "Toggle Pause In Background",
7596 "This action will change whether ZC Player pauses when the window loses focus.",
7597 "",
7598 "Proceed?",
7599 "&Yes",
7600 "&No",
7601 NULL,
7602 'y',
7603 'n',
7604 0,
7605 get_zc_font(font_lfont)) == 1)
7606 {
7607 pause_in_background = pause_in_background ? 0 : 1;
7608 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7609 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7610 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7611 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7612 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7613 }
7614 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7615 return D_O_K;
7616 }
7617
7618 int32_t onKeyboardEntry()
7619 {
7620 NameEntryMode=0;
7621 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7622 return D_O_K;
7623 }
7624
7625 int32_t onLetterGridEntry()
7626 {
7627 NameEntryMode=1;
7628 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7629 return D_O_K;
7630 }
7631
7632 int32_t onExtLetterGridEntry()
7633 {
7634 NameEntryMode=2;
7635 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7636 return D_O_K;
7637 }
7638
7639 static BITMAP* oldscreen;
7640 int32_t onFullscreenMenu()
7641 {
7642 // super hacks
7643 screen = oldscreen;
7644 if (onFullscreen() == D_REDRAW)
7645 {
7646 oldscreen = screen;
7647 }
7648 screen = menu_bmp;
7649 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7650 return D_O_K;
7651 }
7652
7653 117 void fix_menu()
7654 {
7655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(!debug_enabled)
7656 117 settings_menu[13].text = NULL;
7657 117 }
7658
7659 static DIALOG system_dlg[] =
7660 {
7661 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7662 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7663 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onThrottleFPS, NULL, NULL },
7664 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7665 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7666 #ifndef ALLEGRO_MACOSX
7667 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7668 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7669 #else
7670 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7671 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7672 #endif
7673 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7674 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7675 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7676 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7677 };
7678
7679 void reset_snapshot_format_menu()
7680 {
7681 for(int32_t i=0; i<ssfmtMAX; ++i)
7682 {
7683 snapshot_format_menu[i].flags=0;
7684 }
7685 }
7686
7687 int32_t onSetSnapshotFormat()
7688 {
7689 switch(active_menu->text[1])
7690 {
7691 case 'B': //"&BMP"
7692 SnapshotFormat=0;
7693 break;
7694
7695 case 'G': //"&GIF"
7696 SnapshotFormat=1;
7697 break;
7698
7699 case 'J': //"&JPG"
7700 SnapshotFormat=2;
7701 break;
7702
7703 case 'P': //"&PNG"
7704 SnapshotFormat=3;
7705 break;
7706
7707 case 'C': //"PC&X"
7708 SnapshotFormat=4;
7709 break;
7710
7711 case 'T': //"&TGA"
7712 SnapshotFormat=5;
7713 break;
7714
7715 case 'L': //"&LBM"
7716 SnapshotFormat=6;
7717 break;
7718 }
7719 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7720
7721 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7722 return D_O_K;
7723 }
7724
7725
7726 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7727 {
7728 PALETTE tmp;
7729
7730 for(int32_t i=0; i<256; i++)
7731 {
7732 tmp[i].r=r;
7733 tmp[i].g=g;
7734 tmp[i].b=b;
7735 }
7736
7737 fade_interpolate(src,tmp,dest,pos,from,to);
7738 }
7739
7740 14 void system_pal(bool force)
7741 {
7742
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7743 14 is_sys_pal = true;
7744 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7745 14 hw_palette = &syspal;
7746 14 update_hw_pal = true;
7747 14 }
7748
7749 static uint32_t entered_sys_pal = 0;
7750 14 void enter_sys_pal()
7751 {
7752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7753 {
7754 if(entered_sys_pal)
7755 ++entered_sys_pal;
7756 return;
7757 }
7758 14 sys_mouse();
7759 14 system_pal(true);
7760 14 ++entered_sys_pal;
7761 14 }
7762 14 void exit_sys_pal()
7763 {
7764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7765 {
7766
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7767 {
7768 14 game_pal();
7769 14 game_mouse();
7770 14 }
7771 14 }
7772 14 }
7773
7774 void switch_out_callback()
7775 {
7776 if (pause_in_background && !MenuOpen)
7777 {
7778 System();
7779 }
7780 }
7781
7782 void switch_in_callback()
7783 {
7784 }
7785
7786 424 void game_pal()
7787 {
7788 424 is_sys_pal = false;
7789 424 entered_sys_pal = 0;
7790 424 hw_palette = &RAMpal;
7791 424 update_hw_pal = true;
7792 424 }
7793
7794 static char bar_str[] = "";
7795
7796 14 void music_pause()
7797 {
7798 //al_pause_duh(tmplayer);
7799 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7801 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7802 14 zc_midi_pause();
7803 14 }
7804
7805 void music_resume()
7806 {
7807 //al_resume_duh(tmplayer);
7808 zcmusic_pause(zcmusic, ZCM_RESUME);
7809 if (zcmixer->oldtrack)
7810 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7811 zc_midi_resume();
7812 }
7813
7814 3361 void music_stop()
7815 {
7816 //al_stop_duh(tmplayer);
7817 //unload_duh(tmusic);
7818 //tmusic=NULL;
7819 //tmplayer=NULL;
7820 3361 zcmusic_stop(zcmusic);
7821 3361 zcmusic_unload_file(zcmusic);
7822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if (zcmixer->oldtrack)
7823 {
7824 zcmusic_stop(zcmixer->oldtrack);
7825 zcmusic_unload_file(zcmixer->oldtrack);
7826 }
7827 3361 zcmixer->newtrack = NULL;
7828 3361 zc_stop_midi();
7829 3361 currmidi=-1;
7830 3361 }
7831
7832 void System()
7833 {
7834 mouse_down=gui_mouse_b();
7835 music_pause();
7836 pause_all_sfx();
7837 MenuOpen = true;
7838 enter_sys_pal();
7839 // FONT *oldfont=font;
7840 // font=tfont;
7841
7842 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7843 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7844
7845 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7846 #if DEVLEVEL > 1
7847 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7848 #endif
7849 game_menu[3].flags =
7850 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7851 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7852 clear_keybuf();
7853
7854 DIALOG_PLAYER *p;
7855
7856 clear_bitmap(menu_bmp);
7857 oldscreen = screen;
7858 screen = menu_bmp;
7859
7860 p = init_dialog(system_dlg,-1);
7861
7862 // drop the menu on startup if menu button pressed
7863 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7864 simulate_keypress(KEY_G << 8);
7865
7866 do
7867 {
7868 if(handle_close_btn_quit())
7869 break;
7870
7871 rest(17);
7872
7873 if(mouse_down && !gui_mouse_b())
7874 mouse_down=0;
7875
7876 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7877 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7878 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7879 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7880 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7881 settings_menu[10].flags = NESquit?D_SELECTED:0;
7882 settings_menu[11].flags = volkeys?D_SELECTED:0;
7883
7884 window_menu[0].flags = DragAspect?D_SELECTED:0;
7885 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7886 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7887 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7888 window_menu[4].flags = stretchGame?D_SELECTED:0;
7889
7890 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7891 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7892
7893 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7894 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7895 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7896
7897 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7898 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7899 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7900
7901 bool nocheat = (replay_is_replaying() || !Playing
7902 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7903 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7904 cheat_menu[0].flags = 0;
7905 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7906 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7907 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7908 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7909 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7910 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7911 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7912 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7913 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7914
7915 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7916 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7917 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7918 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7919 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7920 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7921 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7922 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7923 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7924 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7925 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7926 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7927 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7928 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7929 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7930
7931 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7932 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7933
7934 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7935 (char *)"Disable recording new saves" :
7936 (char *)"Enable recording new saves";
7937 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7938 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7939 (char *)"Stop recording" :
7940 (char *)"Stop replaying";
7941 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7942 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7943 (char *)"Disable snapshot all frames" :
7944 (char *)"Enable snapshot all frames";
7945
7946 reset_snapshot_format_menu();
7947 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7948
7949 if(debug_enabled)
7950 {
7951 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7952 }
7953
7954 if(gui_mouse_b() && !mouse_down)
7955 break;
7956
7957 // press menu to drop the menu
7958 if(rMbtn())
7959 simulate_keypress(KEY_G << 8);
7960
7961 if(input_idle(true) > after_time())
7962 // run Screeen Saver
7963 {
7964 // Screen saver enabled for now.
7965 clear_keybuf();
7966 Matrix(ss_speed, ss_density, 0);
7967 system_pal(true);
7968 sys_mouse();
7969 broadcast_dialog_message(MSG_DRAW, 0);
7970 }
7971
7972 update_hw_screen();
7973 }
7974 while(update_dialog(p));
7975
7976 screen = oldscreen;
7977
7978 // font=oldfont;
7979 mouse_down=gui_mouse_b();
7980 shutdown_dialog(p);
7981 MenuOpen = false;
7982 if(Quit)
7983 {
7984 kill_sfx();
7985 music_stop();
7986 update_hw_screen();
7987 }
7988 else
7989 {
7990 music_resume();
7991 resume_all_sfx();
7992
7993 if(rc)
7994 ringcolor(false);
7995 }
7996 exit_sys_pal();
7997
7998 eat_buttons();
7999
8000 rc=false;
8001 clear_keybuf();
8002
8003 zc_init_apply_cheat_delta();
8004 }
8005
8006 117 void fix_dialogs()
8007 {
8008 117 jwin_center_dialog(about_dlg);
8009 117 jwin_center_dialog(gamepad_dlg);
8010 117 jwin_center_dialog(credits_dlg);
8011 117 jwin_center_dialog(gamemode_dlg);
8012 117 jwin_center_dialog(getnum_dlg);
8013 117 jwin_center_dialog(goto_dlg);
8014 117 jwin_center_dialog(keyboard_control_dlg);
8015 117 jwin_center_dialog(midi_dlg);
8016 117 jwin_center_dialog(quest_dlg);
8017 117 jwin_center_dialog(scrsaver_dlg);
8018 117 jwin_center_dialog(sound_dlg);
8019 117 jwin_center_dialog(triforce_dlg);
8020
8021 // digi_dp[1] += scrx;
8022 // digi_dp[2] += scry;
8023 // midi_dp[1] += scrx;
8024 // midi_dp[2] += scry;
8025 // pan_dp[1] += scrx;
8026 // pan_dp[2] += scry;
8027 // emus_dp[1] += scrx;
8028 // emus_dp[2] += scry;
8029 // buf_dp[1] += scrx;
8030 // buf_dp[2] += scry;
8031 // sfx_dp[1] += scrx;
8032 // sfx_dp[2] += scry;
8033 117 }
8034
8035 /*****************************/
8036 /**** Custom Sound System ****/
8037 /*****************************/
8038
8039 117 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8040 {
8041
2/4
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
117 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8042 }
8043
8044 149 int32_t get_emusic_volume()
8045 {
8046 149 int32_t temp_volume = emusic_volume;
8047
2/4
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
149 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8048 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (!zcmusic)
8050 149 return temp_volume;
8051 return (temp_volume * zcmusic->fadevolume) / 10000;
8052 149 }
8053
8054 int32_t get_zcmusicpos()
8055 {
8056 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8057 return debugtracething;
8058 return 0;
8059 }
8060
8061 void set_zcmusicpos(int32_t position)
8062 {
8063 zcmusic_set_curpos(zcmusic, position);
8064 }
8065
8066 void set_zcmusicspeed(int32_t speed)
8067 {
8068 zcmusic_set_speed(zcmusic, speed);
8069 }
8070
8071 int32_t get_zcmusiclen()
8072 {
8073 return zcmusic_get_length(zcmusic);
8074 }
8075
8076 void set_zcmusicloop(double start, double end)
8077 {
8078 zcmusic_set_loop(zcmusic, start, end);
8079 }
8080
8081 63941 void jukebox(int32_t index,int32_t loop)
8082 {
8083
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8084 63941 return;
8085
8086 music_stop();
8087
8088 if(index<0) index=MAXMIDIS-1;
8089
8090 if(index>=MAXMIDIS) index=0;
8091
8092 music_stop();
8093
8094 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8095 // stuck notes when a song stops. This fixes it.
8096 if(strcmp(midi_driver->name, "DIGMID")==0)
8097 zc_set_volume(0, 0);
8098
8099 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8100 zc_play_midi((MIDI*)tunes[index].data,loop);
8101
8102 if(tunes[index].start>0)
8103 zc_midi_seek(tunes[index].start);
8104
8105 midi_loop_start = tunes[index].loop_start;
8106 midi_loop_end = tunes[index].loop_end;
8107
8108 currmidi=index;
8109 master_volume(digi_volume, midi_volume);
8110 //midi_paused=false;
8111 63941 }
8112
8113 63941 void jukebox(int32_t index)
8114 {
8115
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8116
8117
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8118
8119 // do nothing if it's already playing
8120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8121 {
8122 return;
8123 }
8124
8125 63941 jukebox(index,tunes[index].loop);
8126 63941 }
8127
8128 16 void play_DmapMusic()
8129 {
8130
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8131 16 return;
8132
8133 static char tfile[2048];
8134 static int32_t ttrack=0;
8135 bool domidi=false;
8136
8137 int32_t fadeoutframes = 0;
8138 if (zcmusic != NULL)
8139 fadeoutframes = zcmusic->fadeoutframes;
8140
8141 if(DMaps[currdmap].tmusic[0]!=0)
8142 {
8143 if(zcmusic==NULL ||
8144 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8145 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8146 {
8147 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8148 {
8149 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8150 {
8151 if (zcmusic != NULL)
8152 {
8153 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8154 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8155 }
8156 }
8157 }
8158 else
8159 {
8160 if (zcmusic != NULL)
8161 {
8162 zcmusic_stop(zcmusic);
8163 zcmusic_unload_file(zcmusic);
8164 zcmusic = NULL;
8165 zcmixer->newtrack = NULL;
8166 }
8167
8168 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8169 zcmixer->newtrack = zcmusic;
8170
8171 if (zcmusic != NULL)
8172 {
8173 zc_stop_midi();
8174 strcpy(tfile, DMaps[currdmap].tmusic);
8175 zcmusic_play(zcmusic, emusic_volume);
8176 int32_t temptracks = 0;
8177 temptracks = zcmusic_get_tracks(zcmusic);
8178 temptracks = (temptracks < 2) ? 1 : temptracks;
8179 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8180 zcmusic_change_track(zcmusic, ttrack);
8181 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8182 }
8183 else
8184 {
8185 tfile[0] = 0;
8186 domidi = true;
8187 }
8188 }
8189 }
8190 }
8191 else
8192 {
8193 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8194 {
8195 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8196 }
8197 else
8198 {
8199 domidi = true;
8200 }
8201 }
8202
8203 if(domidi)
8204 {
8205 int32_t m=DMaps[currdmap].midi;
8206
8207 switch(m)
8208 {
8209 case 1:
8210 jukebox(ZC_MIDI_OVERWORLD);
8211 break;
8212
8213 case 2:
8214 jukebox(ZC_MIDI_DUNGEON);
8215 break;
8216
8217 case 3:
8218 jukebox(ZC_MIDI_LEVEL9);
8219 break;
8220
8221 default:
8222 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8223 jukebox(m+MIDIOFFSET_DMAP);
8224 else
8225 music_stop();
8226 }
8227 }
8228 16 }
8229
8230 15755 void playLevelMusic()
8231 {
8232
1/2
✓ Branch 0 taken 15755 times.
✗ Branch 1 not taken.
15755 if (is_headless())
8233 15755 return;
8234
8235 int32_t m=tmpscr->screen_midi;
8236
8237 switch(m)
8238 {
8239 case -2:
8240 music_stop();
8241 break;
8242
8243 case -1:
8244 play_DmapMusic();
8245 break;
8246
8247 case 1:
8248 jukebox(ZC_MIDI_OVERWORLD);
8249 break;
8250
8251 case 2:
8252 jukebox(ZC_MIDI_DUNGEON);
8253 break;
8254
8255 case 3:
8256 jukebox(ZC_MIDI_LEVEL9);
8257 break;
8258
8259 default:
8260 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8261 jukebox(m+MIDIOFFSET_MAPSCR);
8262 else
8263 music_stop();
8264 }
8265 15755 }
8266
8267 117 void master_volume(int32_t dv,int32_t mv)
8268 {
8269
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
117 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8270
8271
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
117 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8272
8273
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
117 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8274 117 int32_t temp_vol = midi_volume;
8275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8276 117 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8277 117 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8278 117 }
8279
8280 /*****************/
8281 /***** SFX *****/
8282 /*****************/
8283
8284 // array of voices, one for each sfx sample in the data file
8285 // 0+ = voice #
8286 // -1 = voice not allocated
8287 117 void Z_init_sound()
8288 {
8289
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<WAV_COUNT; i++)
8290 29952 sfx_voice[i]=-1;
8291
8292 117 const char* midis[ZC_MIDI_COUNT] = {
8293 "assets/dungeon.mid",
8294 "assets/ending.mid",
8295 "assets/gameover.mid",
8296 "assets/level9.mid",
8297 "assets/overworld.mid",
8298 "assets/title.mid",
8299 "assets/triforce.mid",
8300 };
8301
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 117 times.
936 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8302 {
8303 819 tunes[i].data = load_midi(midis[i]);
8304
1/2
✓ Branch 0 taken 819 times.
✗ Branch 1 not taken.
819 if (!tunes[i].data)
8305 Z_error_fatal("Missing required file %s\n", midis[i]);
8306 819 }
8307
8308
2/2
✓ Branch 0 taken 29484 times.
✓ Branch 1 taken 117 times.
29601 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8309 29484 tunes[ZC_MIDI_COUNT+j].data=NULL;
8310
8311 117 master_volume(digi_volume,midi_volume);
8312 117 }
8313
8314 // returns number of voices currently allocated
8315 int32_t sfx_count()
8316 {
8317 int32_t c=0;
8318
8319 for(int32_t i=0; i<WAV_COUNT; i++)
8320 if(sfx_voice[i]!=-1)
8321 ++c;
8322
8323 return c;
8324 }
8325
8326 // clean up finished samples
8327 9218467 void sfx_cleanup()
8328 {
8329
2/2
✓ Branch 0 taken 2359927552 times.
✓ Branch 1 taken 9218467 times.
2369146019 for(int32_t i=0; i<WAV_COUNT; i++)
8330
3/4
✓ Branch 0 taken 619766 times.
✓ Branch 1 taken 2359307786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619766 times.
2360547318 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8331 {
8332 619766 deallocate_voice(sfx_voice[i]);
8333 619766 sfx_voice[i]=-1;
8334 619766 }
8335 9218467 }
8336
8337 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8338 // if a voice is already allocated (and/or playing), then it just returns true
8339 // Returns true: voice is allocated
8340 // false: unsuccessful
8341 964184 bool sfx_init(int32_t index)
8342 {
8343 // check index
8344
3/4
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721795 times.
964184 if(index<=0 || index>=WAV_COUNT)
8345 242389 return false;
8346
8347
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619784 times.
721795 if(sfx_voice[index]==-1)
8348 {
8349
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409908 times.
619784 if(sfxdat)
8350 {
8351
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8352 {
8353 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8354 209876 }
8355 else
8356 {
8357 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8358 }
8359 209876 }
8360 else
8361 {
8362 409908 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8363 }
8364
8365 619784 int32_t temp_volume = sfx_volume;
8366
2/4
✓ Branch 0 taken 619784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619784 times.
✗ Branch 3 not taken.
619784 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8367 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8368 619784 voice_set_volume(sfx_voice[index], temp_volume);
8369 619784 }
8370
8371 721795 return sfx_voice[index] != -1;
8372 964184 }
8373
8374 int32_t sfx_get_default_freq(int32_t index)
8375 {
8376 if (sfxdat)
8377 {
8378 if (index < Z35)
8379 {
8380 return ((SAMPLE*)sfxdata[index].dat)->freq;
8381 }
8382 else
8383 {
8384 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8385 }
8386 }
8387 else
8388 {
8389 return customsfxdata[index].freq;
8390 }
8391 }
8392
8393 int32_t sfx_get_length(int32_t index)
8394 {
8395 if (sfxdat)
8396 {
8397 if (index < Z35)
8398 {
8399 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8400 }
8401 else
8402 {
8403 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8404 }
8405 }
8406 else
8407 {
8408 return int32_t(customsfxdata[index].len);
8409 }
8410 }
8411
8412 // plays an sfx sample
8413 964184 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8414 {
8415
2/2
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
964184 if(!sfx_init(index))
8416 242389 return;
8417
1/2
✓ Branch 0 taken 721795 times.
✗ Branch 1 not taken.
721795 if (!is_headless())
8418 {
8419 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8420 voice_set_pan(sfx_voice[index], pan);
8421
8422 // Only used by ZScript currently
8423 if (freq <= -1)
8424 {
8425 freq = sfx_get_default_freq(index);
8426 }
8427 voice_set_frequency(sfx_voice[index], freq);
8428
8429 // Only used by ZScript currently
8430 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8431 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8432 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8433 voice_set_volume(sfx_voice[index], temp_volume);
8434
8435 int32_t pos = voice_get_position(sfx_voice[index]);
8436
8437 if (restart) voice_set_position(sfx_voice[index], 0);
8438
8439 if (pos <= 0)
8440 voice_start(sfx_voice[index]);
8441 }
8442
8443
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721795 if (restart && replay_is_debug())
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8445 964184 }
8446
8447 // true if sfx is allocated
8448 68052 bool sfx_allocated(int32_t index)
8449 {
8450
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8451 }
8452
8453 // start it (in loop mode) if it's not already playing,
8454 // otherwise adjust it to play in loop mode -DD
8455 55174 void cont_sfx(int32_t index)
8456 {
8457
1/2
✓ Branch 0 taken 55174 times.
✗ Branch 1 not taken.
55174 if (is_headless())
8458 55174 return;
8459
8460 if(!sfx_init(index))
8461 {
8462 return;
8463 }
8464
8465 if(voice_get_position(sfx_voice[index])<=0)
8466 {
8467 voice_set_position(sfx_voice[index],0);
8468 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8469 voice_start(sfx_voice[index]);
8470 }
8471 else
8472 {
8473 adjust_sfx(index, 128, true);
8474 }
8475 55174 }
8476
8477 // adjust parameters while playing
8478 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8479 {
8480
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8481 4075 return;
8482
8483 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8484 voice_set_pan(sfx_voice[index],pan);
8485 4075 }
8486
8487 // pauses a voice
8488 1725 void pause_sfx(int32_t index)
8489 {
8490
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8491 voice_stop(sfx_voice[index]);
8492 1725 }
8493
8494 // resumes a voice
8495 747 void resume_sfx(int32_t index)
8496 {
8497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8498 747 return;
8499
8500 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8501 voice_start(sfx_voice[index]);
8502 747 }
8503
8504 // pauses all active voices
8505 452 void pause_all_sfx()
8506 {
8507
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8508
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8509 1 voice_stop(sfx_voice[i]);
8510 452 }
8511
8512 // resumes all paused voices
8513 438 void resume_all_sfx()
8514 {
8515
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8516
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8517 voice_start(sfx_voice[i]);
8518 438 }
8519
8520 // stops an sfx and deallocates the voice
8521 7462663 void stop_sfx(int32_t index)
8522 {
8523
3/4
✓ Branch 0 taken 6277597 times.
✓ Branch 1 taken 1185066 times.
✓ Branch 2 taken 6277597 times.
✗ Branch 3 not taken.
7462663 if(index<=0 || index>=WAV_COUNT)
8524 1185066 return;
8525
8526
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6277585 times.
6277597 if(sfx_voice[index]!=-1)
8527 {
8528 12 deallocate_voice(sfx_voice[index]);
8529 12 sfx_voice[index]=-1;
8530 12 }
8531 7462663 }
8532
8533 // Stops SFX played by Hero's item of the given family
8534 128638 void stop_item_sfx(int32_t family)
8535 {
8536 128638 int32_t id=current_item_id(family);
8537
8538
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8539 128083 return;
8540
8541 555 stop_sfx(itemsbuf[id].usesound);
8542 128638 }
8543
8544 3223 void kill_sfx()
8545 {
8546
2/2
✓ Branch 0 taken 825088 times.
✓ Branch 1 taken 3223 times.
828311 for(int32_t i=0; i<WAV_COUNT; i++)
8547
2/2
✓ Branch 0 taken 825082 times.
✓ Branch 1 taken 6 times.
825094 if(sfx_voice[i]!=-1)
8548 {
8549 6 deallocate_voice(sfx_voice[i]);
8550 6 sfx_voice[i]=-1;
8551 6 }
8552 3223 }
8553
8554 659811 int32_t pan(int32_t x)
8555 {
8556
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8557 {
8558 case 0:
8559 return 128;
8560
8561 case 1:
8562 659811 return vbound((x>>1)+68,0,255);
8563
8564 case 2:
8565 return vbound(((x*3)>>2)+36,0,255);
8566 }
8567
8568 return vbound(x,0,255);
8569 659811 }
8570
8571 /*******************************/
8572 /******* Input Handlers ********/
8573 /*******************************/
8574
8575 25094006 bool joybtn(int32_t b)
8576 {
8577
1/2
✓ Branch 0 taken 25094006 times.
✗ Branch 1 not taken.
25094006 if(b == 0)
8578 return false;
8579
1/2
✓ Branch 0 taken 25094006 times.
✗ Branch 1 not taken.
25094006 if (b-1 >= joy[joystick_index].num_buttons)
8580 25094006 return false;
8581
8582 return joy[joystick_index].button[b-1].b !=0;
8583 25094006 }
8584
8585 bool joystick(int32_t s)
8586 {
8587 if(s < 0)
8588 return false;
8589 if (s >= joy[joystick_index].num_sticks)
8590 return false;
8591
8592 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8593 {
8594 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8595 return true;
8596 }
8597 return false;
8598 }
8599
8600 const char* joybtn_name(int32_t b)
8601 {
8602 if (b <= 0 || b > joy[joystick_index].num_buttons)
8603 return "";
8604
8605 return joy[joystick_index].button[b-1].name;
8606 }
8607
8608 const char* joystick_name(int32_t s)
8609 {
8610 if (s < 0 || s >= joy[joystick_index].num_sticks)
8611 return "";
8612
8613 return joy[joystick_index].stick[s].name;
8614 }
8615
8616 int32_t next_press_key();
8617
8618 int32_t next_joy_input(bool buttons)
8619 {
8620 clear_keybuf();
8621
8622 //first, we need to wait until they're pressing no buttons
8623 for(;;)
8624 {
8625 if(keypressed())
8626 {
8627 switch(readkey()>>8)
8628 {
8629 case KEY_ESC:
8630 return -1;
8631
8632 case KEY_SPACE:
8633 return 0;
8634 }
8635 }
8636
8637 poll_joystick();
8638 bool done = true;
8639
8640 if (buttons)
8641 {
8642 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8643 {
8644 if(joybtn(i)) done = false;
8645 }
8646 }
8647 else
8648 {
8649 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8650 {
8651 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8652 return -2;
8653 }
8654 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8655 {
8656 if(joystick(i)) done = false;
8657 }
8658 }
8659
8660 if(done) break;
8661 rest(1);
8662 }
8663
8664 //now, we need to wait for them to press any button
8665 for(;;)
8666 {
8667 if(keypressed())
8668 {
8669 switch(readkey()>>8)
8670 {
8671 case KEY_ESC:
8672 return -1;
8673
8674 case KEY_SPACE:
8675 return 0;
8676 }
8677 }
8678
8679 poll_joystick();
8680
8681 if (buttons)
8682 {
8683 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8684 {
8685 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8686 return -2;
8687 }
8688 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8689 {
8690 if(joybtn(i))
8691 return i;
8692 }
8693 }
8694 else
8695 {
8696 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8697 {
8698 if(joystick(i))
8699 return i;
8700 }
8701 }
8702 rest(1);
8703 }
8704 }
8705
8706 1209106 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8707 {
8708
2/2
✓ Branch 0 taken 1204755 times.
✓ Branch 1 taken 4351 times.
1209106 bool ret = btn && !flag;
8709 1209106 flag = rawbtn;
8710
8711 1209106 return ret;
8712 }
8713 190805710 static bool rButton(bool &btn, bool &flag)
8714 {
8715
2/2
✓ Branch 0 taken 183961269 times.
✓ Branch 1 taken 6844441 times.
190805710 bool ret = btn && !flag;
8716 190805710 flag = btn;
8717
8718 190805710 return ret;
8719 }
8720 2888985 static bool rButtonPeek(bool btn, bool flag)
8721 {
8722
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8723 {
8724 2685887 return false;
8725 }
8726
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8727 {
8728 17939 return true;
8729 }
8730
8731 185159 return false;
8732 2888985 }
8733
8734 // Updated only by keyboard/gamepad.
8735 // If in replay mode, this is set directly by the replay system.
8736 // This should never be read from directly - use control_state instead.
8737 bool raw_control_state[ZC_CONTROL_STATES];
8738
8739 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8740 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8741 // lasts until the next call to load_control_state.
8742 bool control_state[ZC_CONTROL_STATES];
8743 bool disable_control[ZC_CONTROL_STATES];
8744 bool drunk_toggle_state[11];
8745 bool disabledKeys[127];
8746 bool KeyInput[127];
8747 bool KeyPress[127];
8748
8749 bool key_current_frame[127];
8750 bool key_previous_frame[127];
8751
8752 static bool key_system[127];
8753 static bool key_system_previous[127];
8754 static bool key_system_press[127];
8755
8756 bool button_press[ZC_CONTROL_STATES];
8757 bool button_hold[ZC_CONTROL_STATES];
8758
8759 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8760 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8761 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8762 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8763 #define STICK_PRECISION 56 //define your own sensitivity
8764
8765 7801176 void load_control_state()
8766 {
8767 7801176 load_control_called_this_frame = true;
8768
8769
2/2
✓ Branch 0 taken 4833663 times.
✓ Branch 1 taken 2967513 times.
7801176 if (replay_version_check(8, 11))
8770 {
8771
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8772 53415234 down_control_states[i] = raw_control_state[i];
8773 2967513 }
8774
8775
1/2
✓ Branch 0 taken 7801176 times.
✗ Branch 1 not taken.
7801176 if (!replay_is_replaying())
8776 {
8777 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8778 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8779 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8780 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8781 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8782 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8783 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8784 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8785 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8786 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8787 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8788 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8789 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8790 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8791
8792 if(num_joysticks != 0)
8793 {
8794 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8795 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8796 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8797 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8798 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8799 }
8800 else
8801 {
8802 raw_control_state[14] = false;
8803 raw_control_state[15] = false;
8804 raw_control_state[16] = false;
8805 raw_control_state[17] = false;
8806 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8807 }
8808 }
8809
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7801173 times.
7801176 if (replay_is_active())
8810 {
8811
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785958 times.
7801173 if (replay_get_version() < 3)
8812 1015215 replay_poll();
8813
3/4
✓ Branch 0 taken 6785958 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5024583 times.
✓ Branch 3 taken 1761375 times.
6785958 else if (replay_is_replaying() && replay_get_version() < 6)
8814 1761375 replay_peek_input();
8815
3/4
✓ Branch 0 taken 5024583 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2057070 times.
✓ Branch 3 taken 2967513 times.
5024583 else if (replay_is_replaying() && replay_version_check(8, 11))
8816 2967513 replay_peek_input();
8817
2/2
✓ Branch 0 taken 6696883 times.
✓ Branch 1 taken 1104290 times.
7801173 if (replay_get_version() == 8)
8818 1104290 update_keys();
8819 7801173 }
8820
8821 // Some test replay files were made before a serious input bug was fixed, so instead
8822 // of re-doing them or tossing them out, just check for that zplay version.
8823
3/4
✓ Branch 0 taken 7801170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7679270 times.
7801176 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8824
2/2
✓ Branch 0 taken 140421060 times.
✓ Branch 1 taken 7801170 times.
148222230 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8825 {
8826 140421060 control_state[i] = raw_control_state[i];
8827
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90933750 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140421060 if (botched_input && !control_state[i])
8828 47077142 down_control_states[i] = false;
8829 140421060 }
8830 7801170 bool did_bad_cutscene_btn = false;
8831
2/2
✓ Branch 0 taken 7801170 times.
✓ Branch 1 taken 140421060 times.
148222230 for(int q = 0; q < 18; ++q)
8832
4/4
✓ Branch 0 taken 6465003 times.
✓ Branch 1 taken 133956057 times.
✓ Branch 2 taken 6464269 times.
✓ Branch 3 taken 734 times.
140421794 if(control_state[q] && !active_cutscene.can_button(q))
8833 {
8834 734 control_state[q] = false;
8835 734 did_bad_cutscene_btn = true;
8836 734 }
8837
2/2
✓ Branch 0 taken 7800655 times.
✓ Branch 1 taken 515 times.
7801170 if(did_bad_cutscene_btn)
8838 515 active_cutscene.error();
8839
8840 7801170 button_press[0]=rButton(control_state[0],button_hold[0]);
8841 7801170 button_press[1]=rButton(control_state[1],button_hold[1]);
8842 7801170 button_press[2]=rButton(control_state[2],button_hold[2]);
8843 7801170 button_press[3]=rButton(control_state[3],button_hold[3]);
8844 7801170 button_press[4]=rButton(control_state[4],button_hold[4]);
8845 7801170 button_press[5]=rButton(control_state[5],button_hold[5]);
8846 7801170 button_press[6]=rButton(control_state[6],button_hold[6]);
8847 7801170 button_press[7]=rButton(control_state[7],button_hold[7]);
8848 7801170 button_press[8]=rButton(control_state[8],button_hold[8]);
8849 7801170 button_press[9]=rButton(control_state[9],button_hold[9]);
8850 7801170 button_press[10]=rButton(control_state[10],button_hold[10]);
8851 7801170 button_press[11]=rButton(control_state[11],button_hold[11]);
8852 7801170 button_press[12]=rButton(control_state[12],button_hold[12]);
8853 7801170 button_press[13]=rButton(control_state[13],button_hold[13]);
8854 7801170 button_press[14]=rButton(control_state[14],button_hold[14]);
8855 7801170 button_press[15]=rButton(control_state[15],button_hold[15]);
8856 7801170 button_press[16]=rButton(control_state[16],button_hold[16]);
8857 7801170 button_press[17]=rButton(control_state[17],button_hold[17]);
8858 7801170 }
8859
8860 // Returns true if any game key is pressed. This is needed because keypressed()
8861 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8862 40250637 bool zc_key_pressed()
8863 //may also need to use zc_getrawkey
8864 {
8865
7/10
✓ Branch 0 taken 32597771 times.
✓ Branch 1 taken 7652866 times.
✓ Branch 2 taken 7652866 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652866 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396392 times.
✓ Branch 7 taken 6396392 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461754 times.
42712391 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8866
4/6
✓ Branch 0 taken 6396392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4844168 times.
✓ Branch 5 taken 4844168 times.
6396392 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8867
4/6
✓ Branch 0 taken 4844168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4844168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143220 times.
✓ Branch 5 taken 3143220 times.
4844168 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8868
4/6
✓ Branch 0 taken 3143220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732278 times.
✓ Branch 5 taken 2732278 times.
3143220 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8869
1/2
✓ Branch 0 taken 2732278 times.
✗ Branch 1 not taken.
2732278 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8870
3/4
✓ Branch 0 taken 2612871 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612871 times.
✗ Branch 3 not taken.
2732278 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8871
3/4
✓ Branch 0 taken 2493968 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493968 times.
✗ Branch 3 not taken.
2612871 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8872
3/4
✓ Branch 0 taken 2478823 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478823 times.
✗ Branch 3 not taken.
2493968 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8873
3/4
✓ Branch 0 taken 2465324 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465324 times.
✗ Branch 3 not taken.
2478823 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8874
3/4
✓ Branch 0 taken 2462830 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462830 times.
✗ Branch 3 not taken.
2465324 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8875
3/4
✓ Branch 0 taken 2462612 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462612 times.
✗ Branch 3 not taken.
2462830 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8876
3/4
✓ Branch 0 taken 2461773 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461773 times.
✗ Branch 3 not taken.
2462612 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8877
2/4
✓ Branch 0 taken 2461773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461773 times.
✗ Branch 3 not taken.
2461773 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8878
2/2
✓ Branch 0 taken 2461754 times.
✓ Branch 1 taken 19 times.
2461773 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8879 72020999 return true;
8880
8881 2461754 return false;
8882 9287211 }
8883
8884 149956017 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8885 {
8886 149956017 bool ret = false, drunkstate = false, rawret = false;;
8887 149956017 bool* flag = &down_control_states[btn];
8888
2/7
✓ Branch 0 taken 140659469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9296548 times.
149956017 switch(btn)
8889 {
8890 case btnF12:
8891 ret = zc_getkey(KEY_F12, ignoreDisable);
8892 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8893 eatEntirely = false;
8894 break;
8895 case btnF11:
8896 ret = zc_getkey(KEY_F11, ignoreDisable);
8897 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8898 eatEntirely = false;
8899 break;
8900 case btnF5:
8901 ret = zc_getkey(KEY_F5, ignoreDisable);
8902 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8903 eatEntirely = false;
8904 break;
8905 case btnQ:
8906 ret = zc_getkey(KEY_Q, ignoreDisable);
8907 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8908 eatEntirely = false;
8909 break;
8910 case btnI:
8911 ret = zc_getkey(KEY_I, ignoreDisable);
8912 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8913 eatEntirely = false;
8914 break;
8915 case btnM:
8916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9296548 times.
9296548 if(FFCore.kb_typing_mode) return false;
8917 9296548 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8918 9296548 eatEntirely = false;
8919 9296548 break;
8920 default: //control_state[] index
8921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140659469 times.
140659469 if(FFCore.kb_typing_mode) return false;
8922
5/6
✓ Branch 0 taken 139859690 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2237468 times.
✓ Branch 3 taken 137622222 times.
✓ Branch 4 taken 2237468 times.
✗ Branch 5 not taken.
140659469 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8923
2/2
✓ Branch 0 taken 8036378 times.
✓ Branch 1 taken 132623091 times.
140659469 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8924
4/4
✓ Branch 0 taken 126521127 times.
✓ Branch 1 taken 14138342 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14135338 times.
154797811 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8925 140659469 rawret = raw_control_state[btn];
8926 140659469 }
8927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149956017 times.
149956017 assert(flag);
8928
2/2
✓ Branch 0 taken 95473276 times.
✓ Branch 1 taken 54482741 times.
149956017 if(press)
8929 {
8930
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51593756 times.
54482741 if(peek)
8931 2888985 ret = rButtonPeek(ret, *flag);
8932
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1209106 times.
51593756 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8933 1209106 else ret = rButton(ret, *flag, rawret);
8934 54482741 }
8935
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149956017 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149956017 if(eatEntirely && ret) control_state[btn] = false;
8936
3/4
✓ Branch 0 taken 112376241 times.
✓ Branch 1 taken 37579776 times.
✓ Branch 2 taken 112376241 times.
✗ Branch 3 not taken.
149956017 if(drunk && drunkstate) ret = !ret;
8937 149956017 return ret;
8938 149956017 }
8939
8940 7465295 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8941 {
8942 7465295 byte ret = 0;
8943
2/2
✓ Branch 0 taken 5485975 times.
✓ Branch 1 taken 1979320 times.
7465295 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8944
2/2
✓ Branch 0 taken 7334481 times.
✓ Branch 1 taken 130814 times.
7465295 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8945
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8946
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8947
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8948
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8949
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8950
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8951 7465295 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8952 }
8953
8954 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8955 {
8956 1114 return intbtn&vals;
8957 }
8958
8959 1767437 bool Up()
8960 {
8961 1767437 return getInput(btnUp);
8962 }
8963 147234 bool Down()
8964 {
8965 147234 return getInput(btnDown);
8966 }
8967 257723 bool Left()
8968 {
8969 257723 return getInput(btnLeft);
8970 }
8971 286925 bool Right()
8972 {
8973 286925 return getInput(btnRight);
8974 }
8975 164908 bool cAbtn()
8976 {
8977 164908 return getInput(btnA);
8978 }
8979 1411891 bool cBbtn()
8980 {
8981 1411891 return getInput(btnB);
8982 }
8983 bool cSbtn()
8984 {
8985 return getInput(btnS);
8986 }
8987 68744 bool cLbtn()
8988 {
8989 68744 return getInput(btnL);
8990 }
8991 68744 bool cRbtn()
8992 {
8993 68744 return getInput(btnR);
8994 }
8995 bool cPbtn()
8996 {
8997 return getInput(btnP);
8998 }
8999 bool cEx1btn()
9000 {
9001 return getInput(btnEx1);
9002 }
9003 bool cEx2btn()
9004 {
9005 return getInput(btnEx2);
9006 }
9007 bool cEx3btn()
9008 {
9009 return getInput(btnEx3);
9010 }
9011 bool cEx4btn()
9012 {
9013 return getInput(btnEx4);
9014 }
9015 bool AxisUp()
9016 {
9017 return getInput(btnAxisUp);
9018 }
9019 bool AxisDown()
9020 {
9021 return getInput(btnAxisDown);
9022 }
9023 bool AxisLeft()
9024 {
9025 return getInput(btnAxisLeft);
9026 }
9027 bool AxisRight()
9028 {
9029 return getInput(btnAxisRight);
9030 }
9031
9032 bool cMbtn()
9033 {
9034 return getInput(btnM);
9035 }
9036 bool cF12()
9037 {
9038 return getInput(btnF12);
9039 }
9040 bool cF11()
9041 {
9042 return getInput(btnF11);
9043 }
9044 bool cF5()
9045 {
9046 return getInput(btnF5);
9047 }
9048 bool cQ()
9049 {
9050 return getInput(btnQ);
9051 }
9052 bool cI()
9053 {
9054 return getInput(btnI);
9055 }
9056
9057 130270 bool rUp()
9058 {
9059 130270 return getInput(btnUp, true);
9060 }
9061 130174 bool rDown()
9062 {
9063 130174 return getInput(btnDown, true);
9064 }
9065 130122 bool rLeft()
9066 {
9067 130122 return getInput(btnLeft, true);
9068 }
9069 129657 bool rRight()
9070 {
9071 129657 return getInput(btnRight, true);
9072 }
9073 1296 bool rAbtn()
9074 {
9075 1296 return getInput(btnA, true);
9076 }
9077 1296 bool rBbtn()
9078 {
9079 1296 return getInput(btnB, true);
9080 }
9081 7397110 bool rSbtn()
9082 {
9083 7397110 return getInput(btnS, true);
9084 }
9085 9287211 bool rMbtn()
9086 {
9087 9287211 return getInput(btnM, true);
9088 }
9089 129441 bool rLbtn()
9090 {
9091 129441 return getInput(btnL, true);
9092 }
9093 129436 bool rRbtn()
9094 {
9095 129436 return getInput(btnR, true);
9096 }
9097 7333574 bool rPbtn()
9098 {
9099 7333574 return getInput(btnP, true);
9100 }
9101 bool rEx1btn()
9102 {
9103 return getInput(btnEx1, true);
9104 }
9105 bool rEx2btn()
9106 {
9107 return getInput(btnEx2, true);
9108 }
9109 140087 bool rEx3btn()
9110 {
9111 140087 return getInput(btnEx3, true);
9112 }
9113 140087 bool rEx4btn()
9114 {
9115 140087 return getInput(btnEx4, true);
9116 }
9117 bool rAxisUp()
9118 {
9119 return getInput(btnAxisUp, true);
9120 }
9121 bool rAxisDown()
9122 {
9123 return getInput(btnAxisDown, true);
9124 }
9125 bool rAxisLeft()
9126 {
9127 return getInput(btnAxisLeft, true);
9128 }
9129 bool rAxisRight()
9130 {
9131 return getInput(btnAxisRight, true);
9132 }
9133
9134 bool rF11()
9135 {
9136 return getInput(btnF11, true);
9137 }
9138 bool rQ()
9139 {
9140 return getInput(btnQ, true);
9141 }
9142 bool rI()
9143 {
9144 return getInput(btnI, true);
9145 }
9146
9147 18227830 bool DrunkUp()
9148 {
9149 18227830 return getInput(btnUp, false, true);
9150 }
9151 16890614 bool DrunkDown()
9152 {
9153 16890614 return getInput(btnDown, false, true);
9154 }
9155 10289030 bool DrunkLeft()
9156 {
9157 10289030 return getInput(btnLeft, false, true);
9158 }
9159 8834523 bool DrunkRight()
9160 {
9161 8834523 return getInput(btnRight, false, true);
9162 }
9163 8036020 bool DrunkcAbtn()
9164 {
9165 8036020 return getInput(btnA, false, true);
9166 }
9167 8017468 bool DrunkcBbtn()
9168 {
9169 8017468 return getInput(btnB, false, true);
9170 }
9171 7264444 bool DrunkcEx1btn()
9172 {
9173 7264444 return getInput(btnEx1, false, true);
9174 }
9175 7264464 bool DrunkcEx2btn()
9176 {
9177 7264464 return getInput(btnEx2, false, true);
9178 }
9179 bool DrunkcSbtn()
9180 {
9181 return getInput(btnS, false, true);
9182 }
9183 bool DrunkcMbtn()
9184 {
9185 return getInput(btnM, false, true);
9186 }
9187 bool DrunkcLbtn()
9188 {
9189 return getInput(btnL, false, true);
9190 }
9191 bool DrunkcRbtn()
9192 {
9193 return getInput(btnR, false, true);
9194 }
9195 bool DrunkcPbtn()
9196 {
9197 return getInput(btnP, false, true);
9198 }
9199
9200 bool DrunkrUp()
9201 {
9202 return getInput(btnUp, true, true);
9203 }
9204 bool DrunkrDown()
9205 {
9206 return getInput(btnDown, true, true);
9207 }
9208 bool DrunkrLeft()
9209 {
9210 return getInput(btnLeft, true, true);
9211 }
9212 bool DrunkrRight()
9213 {
9214 return getInput(btnRight, true, true);
9215 }
9216 6082228 bool DrunkrAbtn()
9217 {
9218 6082228 return getInput(btnA, true, true);
9219 }
9220 6099060 bool DrunkrBbtn()
9221 {
9222 6099060 return getInput(btnB, true, true);
9223 }
9224 71669 bool DrunkrEx1btn()
9225 {
9226 71669 return getInput(btnEx1, true, true);
9227 }
9228 71662 bool DrunkrEx2btn()
9229 {
9230 71662 return getInput(btnEx2, true, true);
9231 }
9232 bool DrunkrEx3btn()
9233 {
9234 return getInput(btnEx3, true, true);
9235 }
9236 bool DrunkrEx4btn()
9237 {
9238 return getInput(btnEx4, true, true);
9239 }
9240 bool DrunkrSbtn()
9241 {
9242 return getInput(btnS, true, true);
9243 }
9244 bool DrunkrMbtn()
9245 {
9246 return getInput(btnM, true, true);
9247 }
9248 6689226 bool DrunkrLbtn()
9249 {
9250 6689226 return getInput(btnL, true, true);
9251 }
9252 6685751 bool DrunkrRbtn()
9253 {
9254 6685751 return getInput(btnR, true, true);
9255 }
9256 bool DrunkrPbtn()
9257 {
9258 return getInput(btnP, true, true);
9259 }
9260
9261 9337 void eat_buttons()
9262 {
9263 9337 getInput(btnA, true, false, true);
9264 9337 getInput(btnB, true, false, true);
9265 9337 getInput(btnS, true, false, true);
9266 9337 getInput(btnM, true, false, true);
9267 9337 getInput(btnL, true, false, true);
9268 9337 getInput(btnR, true, false, true);
9269 9337 getInput(btnP, true, false, true);
9270 9337 getInput(btnEx1, true, false, true);
9271 9337 getInput(btnEx2, true, false, true);
9272 9337 getInput(btnEx3, true, false, true);
9273 9337 getInput(btnEx4, true, false, true);
9274 9337 }
9275
9276 // Is true for the _first frame_ of a key press.
9277 // But! it is possible that a script manually sets the value of KeyPress,
9278 // in which case it will be restored to the "true" value based on `key_current_frame`
9279 // and `key_previous_frame` on the next frame.
9280 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9281 {
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9284 {
9285 case KEY_F7:
9286 case KEY_F8:
9287 case KEY_F9:
9288 return KeyPress[k];
9289
9290 default:
9291
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9292 }
9293 14 }
9294
9295 // Is true for _every frame_ a key is held down.
9296 // But! it is possible that a script manually sets the value of KeyInput,
9297 // in which case it will be restored to the "true" value based on `key_current_frame`
9298 // on the next frame.
9299 bool zc_getkey(int32_t k, bool ignoreDisable)
9300 {
9301 if(ignoreDisable) return KeyInput[k];
9302 switch(k)
9303 {
9304 case KEY_F7:
9305 case KEY_F8:
9306 case KEY_F9:
9307 return KeyInput[k];
9308
9309 default:
9310 return KeyInput[k] && !disabledKeys[k];
9311 }
9312 }
9313
9314 // Reads (and then clears) the current frame key state directly.
9315 // Scripts can also modify `key_current_frame`.
9316 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9317 {
9318
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9319 {
9320 2 _key[k]=key[k]=key_current_frame[k]=0;
9321 2 return true;
9322 }
9323 301 _key[k]=key[k]=key_current_frame[k]=0;
9324 301 return false;
9325 303 }
9326
9327 // Reads the current frame key state directly.
9328 // Scripts can also modify `key_current_frame`.
9329 63252960 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9330 {
9331
2/2
✓ Branch 0 taken 53965721 times.
✓ Branch 1 taken 9287239 times.
63252960 if(ignoreDisable) return key_current_frame[k];
9332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287239 times.
9287239 switch(k)
9333 {
9334 case KEY_F7:
9335 case KEY_F8:
9336 case KEY_F9:
9337 return key_current_frame[k];
9338
9339 default:
9340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287239 times.
9287239 return key_current_frame[k] && !disabledKeys[k];
9341 }
9342 63252960 }
9343
9344 // Only used for a handful of keys, like tilde and Function keys.
9345 // This state is never read within the game.
9346 // It exists so that all keyboard input still functions during replay,
9347 // without inadvertently doing things like toggling throttling if the player
9348 // presses ~
9349 9287211 bool zc_get_system_key(int32_t k)
9350 {
9351 9287211 return key_system[k];
9352 }
9353
9354 // True for the _first_ frame of a key press.
9355 83584899 bool zc_read_system_key(int32_t k)
9356 {
9357 83584899 return key_system_press[k];
9358 }
9359
9360 1179475797 bool is_system_key(int32_t k)
9361 {
9362
2/2
✓ Branch 0 taken 1095890898 times.
✓ Branch 1 taken 83584899 times.
1179475797 switch (k)
9363 {
9364 case KEY_BACKQUOTE:
9365 case KEY_CLOSEBRACE:
9366 case KEY_END:
9367 case KEY_HOME:
9368 case KEY_OPENBRACE:
9369 case KEY_PGDN:
9370 case KEY_PGUP:
9371 case KEY_TAB:
9372 case KEY_TILDE:
9373 83584899 return true;
9374 }
9375 1095890898 return is_Fkey(k);
9376 1179475797 }
9377
9378 9287211 void update_system_keys()
9379 {
9380
2/2
✓ Branch 0 taken 1179475797 times.
✓ Branch 1 taken 9287211 times.
1188763008 for (int32_t q = 0; q < 127; ++q)
9381 {
9382
2/2
✓ Branch 0 taken 195031431 times.
✓ Branch 1 taken 984444366 times.
1179475797 if (!is_system_key(q))
9383 984444366 continue;
9384
9385 195031431 key_system[q] = key[q];
9386
1/2
✓ Branch 0 taken 195031431 times.
✗ Branch 1 not taken.
195031431 key_system_press[q] = key_system[q] && !key_system_previous[q];
9387 195031431 key_system_previous[q] = key_system[q];
9388 195031431 }
9389 9287211 }
9390
9391 10391501 void update_keys()
9392 {
9393
2/2
✓ Branch 0 taken 1319720627 times.
✓ Branch 1 taken 10391501 times.
1330112128 for (int32_t q = 0; q < 127; ++q)
9394 {
9395 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9396
1/2
✓ Branch 0 taken 1319720627 times.
✗ Branch 1 not taken.
1319720627 if (!replay_is_replaying())
9397 key_current_frame[q] = key[q];
9398
9399
2/2
✓ Branch 0 taken 1309932100 times.
✓ Branch 1 taken 9788527 times.
1319720627 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9400 1319720627 KeyInput[q] = key_current_frame[q];
9401 1319720627 key_previous_frame[q] = key_current_frame[q];
9402 1319720627 }
9403 10391501 }
9404
9405 bool zc_disablekey(int32_t k, bool val)
9406 {
9407 switch(k)
9408 {
9409 case KEY_F7:
9410 case KEY_F8:
9411 case KEY_F9:
9412 return false;
9413
9414 default:
9415 disabledKeys[k] = val;
9416 return true;
9417 }
9418 }
9419
9420 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9421 {
9422 timer=timer;
9423 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9424 }
9425